blob: 365064cbf2e551a67d60e838696980ef8bbb2097 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import { assertEqual, test } from "https://deno.land/x/testing/testing.ts";
import * as logging from "index.ts";
// TODO: establish something more sophisticated
let testOutput = "";
class TestHandler extends logging.handlers.BaseHandler {
_log(level, ...args) {
testOutput += `${level} ${args[0]}\n`;
}
}
logging.setup({
handlers: {
debug: {
level: "DEBUG",
class: TestHandler
},
info: {
level: "INFO",
class: TestHandler
}
},
loggers: {
default: {
level: "DEBUG",
handlers: ["debug"]
},
info: {
level: "INFO",
handlers: ["info"]
}
}
});
const logger = logging.getLogger("default");
const unknownLogger = logging.getLogger("info");
test(function basicTest() {
logger.debug("I should be printed.");
unknownLogger.debug("I should not be printed.");
unknownLogger.info("And I should be printed as well.");
const expectedOutput =
"10 I should be printed.\n20 And I should be printed as well.\n";
assertEqual(testOutput, expectedOutput);
});
|