summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--std/log/handlers.ts2
-rw-r--r--std/log/handlers_test.ts17
2 files changed, 18 insertions, 1 deletions
diff --git a/std/log/handlers.ts b/std/log/handlers.ts
index 1b152c273..0efa7cc26 100644
--- a/std/log/handlers.ts
+++ b/std/log/handlers.ts
@@ -41,7 +41,7 @@ export class BaseHandler {
const value = logRecord[p1 as keyof LogRecord];
// do not interpolate missing values
- if (!value) {
+ if (value == null) {
return match;
}
diff --git a/std/log/handlers_test.ts b/std/log/handlers_test.ts
index 7ff4c4c90..ef4b69000 100644
--- a/std/log/handlers_test.ts
+++ b/std/log/handlers_test.ts
@@ -94,6 +94,23 @@ Deno.test("testFormatterAsString", function (): void {
assertEquals(handler.messages, ["test DEBUG Hello, world!"]);
});
+Deno.test("testFormatterWithEmptyMsg", function () {
+ const handler = new TestHandler("DEBUG", {
+ formatter: "test {levelName} {msg}",
+ });
+
+ handler.handle(
+ new LogRecord({
+ msg: "",
+ args: [],
+ level: LogLevels.DEBUG,
+ loggerName: "default",
+ })
+ );
+
+ assertEquals(handler.messages, ["test DEBUG "]);
+});
+
Deno.test("testFormatterAsFunction", function (): void {
const handler = new TestHandler("DEBUG", {
formatter: (logRecord): string =>