4.x to 5.x
Message formatting
With version 5.x better-logging now adheres to the ISO8601 standard for dates and time stamps. This brings with it some changes to the message formatting context object.
The string format of
ctx.datehas changed fromDD/MM/YYYYtoYYYY-MM-DD.The introduction of a unified
ctx.timehas renderedctx.time12andctx.time24redundant, and they have there for been removed. The string format of the new unifiedctx.timeis as followshh:mm:ss.mmmwhere the additionalmmmat the end stands for milliseconds.
// IN 4.x
betterLogging(console, {
format: (ctx) => `${ctx.date} ${ctx.time24} ${ctx.msg}`,
});
console.log('Hi'); // [25/05/2022] [20:54:58] Hi
// IN 5.x
betterLogging(console, {
format: (ctx) => `${ctx.date} ${ctx.time} ${ctx.msg}`,
});
console.log('Hi'); // [2022-05-25] [20:54:58.298] HiLast updated
Was this helpful?