pino-pretty
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -329,7 +329,16 @@ 'use strict' | ||
function prettifyTime ({ log, timestampKey = TIMESTAMP_KEY, translateFormat = undefined }) { | ||
if (timestampKey in log === false && 'timestamp' in log === false) return undefined | ||
let time = null | ||
if (timestampKey in log) { | ||
time = log[timestampKey] | ||
} else if ('timestamp' in log) { | ||
time = log.timestamp | ||
} | ||
if (time === null) return undefined | ||
if (translateFormat) { | ||
return '[' + formatTime(log[timestampKey] || log.timestamp, translateFormat) + ']' | ||
return '[' + formatTime(time, translateFormat) + ']' | ||
} | ||
return `[${log[timestampKey] || log.timestamp}]` | ||
return `[${time}]` | ||
} |
{ | ||
"name": "pino-pretty", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "Prettifier for Pino log lines", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -255,3 +255,13 @@ 'use strict' | ||
t.test('handles the 0 timestamp', async t => { | ||
let log = { time: 0 } | ||
let str = prettifyTime({ log }) | ||
t.is(str, '[0]') | ||
log = { timestamp: 0 } | ||
str = prettifyTime({ log }) | ||
t.is(str, '[0]') | ||
}) | ||
t.end() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
247096
1732