+ const stream = createReadStream(path)
+
+ const rl = createInterface({
+ input: stream
+ })
+
+ rl.on('line', line => {
+ const log = JSON.parse(line)
+ // Don't know why but loggerFormat does not remove splat key
+ Object.assign(log, { splat: undefined })
+
+ logLevels[log.level](log)
+ })
+
+ stream.once('close', () => res())
+ })
+}
+
+// Thanks: https://stackoverflow.com/a/37014317
+async function getNewestFile (files: string[], basePath: string) {
+ const sorted = await mtimeSortFilesDesc(files, basePath)
+
+ return (sorted.length > 0) ? sorted[0].file : ''
+}
+
+function toTimeFormat (time: string) {
+ const timestamp = Date.parse(time)
+
+ if (isNaN(timestamp) === true) return 'Unknown date'
+
+ return new Date(timestamp).toISOString()
+}