diff --git a/src/logs.js b/src/logs.js index 342c5f1d4..da8b2e63b 100644 --- a/src/logs.js +++ b/src/logs.js @@ -16,6 +16,7 @@ class LogStream extends TransformStream { this._options = Object.assign({ source: 'unknown', format: 'json' }, options); this._decoder = new StringDecoder(); this._soFar = ''; + this._lastknownTimestamp = 0; } _format(line) { @@ -23,8 +24,14 @@ class LogStream extends TransformStream { const data = line.split(' '); // logs are let timestamp = (new Date(data[0])).getTime(); - if (isNaN(timestamp)) timestamp = 0; - const message = line.slice(data[0].length+1); + let message; + if (isNaN(timestamp)) { + timestamp = this._lastknownTimestamp; + message = line; + } else { + this._lastknownTimestamp = timestamp; + message = line.slice(data[0].length+1); + } return JSON.stringify({ realtimeTimestamp: timestamp * 1000, // timestamp info can be missing (0) for app logs via logPaths