mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(std/log): print "{msg}" when log an empty line (#6381)
This commit is contained in:
parent
971dfcf9bb
commit
6844c3ac0e
2 changed files with 18 additions and 1 deletions
|
@ -41,7 +41,7 @@ export class BaseHandler {
|
||||||
const value = logRecord[p1 as keyof LogRecord];
|
const value = logRecord[p1 as keyof LogRecord];
|
||||||
|
|
||||||
// do not interpolate missing values
|
// do not interpolate missing values
|
||||||
if (!value) {
|
if (value == null) {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,23 @@ Deno.test("testFormatterAsString", function (): void {
|
||||||
assertEquals(handler.messages, ["test DEBUG Hello, world!"]);
|
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 {
|
Deno.test("testFormatterAsFunction", function (): void {
|
||||||
const handler = new TestHandler("DEBUG", {
|
const handler = new TestHandler("DEBUG", {
|
||||||
formatter: (logRecord): string =>
|
formatter: (logRecord): string =>
|
||||||
|
|
Loading…
Add table
Reference in a new issue