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.date
has changed fromDD/MM/YYYY
toYYYY-MM-DD
. - The introduction of a unified
ctx.time
has renderedctx.time12
andctx.time24
redundant, and they have there for been removed. The string format of the new unifiedctx.time
is as followshh:mm:ss.mmm
where the additionalmmm
at 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] Hi