summaryrefslogtreecommitdiff
path: root/std/log/README.md
diff options
context:
space:
mode:
authorChris Knight <cknight1234@gmail.com>2020-06-18 11:50:18 +0100
committerGitHub <noreply@github.com>2020-06-18 12:50:18 +0200
commit940f8e8433ae5ec74b2642438849089a0433e512 (patch)
tree7611524db839edc816c5c77fdfeb711cfce6a757 /std/log/README.md
parent78a311aa5f6c56a750aaf3a7d3e8f911acf348d1 (diff)
feat(std/log): expose logger name to LogRecord (#6316)
Diffstat (limited to 'std/log/README.md')
-rw-r--r--std/log/README.md18
1 files changed, 16 insertions, 2 deletions
diff --git a/std/log/README.md b/std/log/README.md
index 87055015c..b5e99525a 100644
--- a/std/log/README.md
+++ b/std/log/README.md
@@ -79,6 +79,7 @@ class LogRecord {
readonly datetime: Date;
readonly level: number;
readonly levelName: string;
+ readonly loggerName: string;
}
```
@@ -208,13 +209,21 @@ await log.setup({
return msg;
}
}),
+
+ anotherFmt: new log.handlers.ConsoleHandler("DEBUG", {
+ formatter: "[{loggerName}] - {levelName} {msg}"
+ }),
},
loggers: {
default: {
- level: "DEBUG",
- handlers: ["stringFmt", "functionFmt"],
+ level: "DEBUG",
+ handlers: ["stringFmt", "functionFmt"],
},
+ dataLogger: {
+ level: "INFO",
+ handlers: ["anotherFmt"],
+ }
}
})
@@ -223,6 +232,11 @@ log.debug("Hello, world!", 1, "two", [3, 4, 5]);
// results in:
[DEBUG] Hello, world! // output from "stringFmt" handler
10 Hello, world!, arg0: 1, arg1: two, arg3: [3, 4, 5] // output from "functionFmt" formatter
+
+// calling
+log.getLogger("dataLogger").error("oh no!");
+// results in:
+[dataLogger] - ERROR oh no! // output from anotherFmt handler
```
#### Custom handlers