diff --git a/lib/utils.js b/lib/utils.js index da7e0636..0796cd09 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -326,9 +326,19 @@ function prettifyObject ({ * string. */ 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 `[${log}]` }