Skip to content

Commit

Permalink
Only log args if they exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
chmac committed Aug 10, 2024
1 parent 8fde5ac commit a7f13f9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { logPackage } from "./deps.ts";
logPackage.setup({
handlers: {
console: new logPackage.ConsoleHandler("DEBUG", {
formatter: (record) =>
`${record.datetime.toISOString()} [${record.levelName}] ${
formatter: function (record) {
const argsString =
record.args.length > 0 ? ` ${JSON.stringify(record.args)}` : "";
return `${record.datetime.toISOString()} [${record.levelName}] ${
record.msg
} ${JSON.stringify(record.args)}`,
} ${argsString}`;
},

useColors: true,
}),
},
Expand Down

0 comments on commit a7f13f9

Please sign in to comment.