Make sure we don't duplicate historical logs when streaming

This commit is contained in:
Tim Perry 2018-07-12 15:23:33 +02:00
parent f9cf0aaf23
commit 4388a248b9

View File

@ -50,11 +50,11 @@ module.exports =
timestamp = moment(line.timestamp).format('DD.MM.YY HH:mm:ss (ZZ)')
console.log("#{timestamp} #{line.message}")
promise = resin.logs.history(params.uuid).each(printLine)
promise = if options.tail
resin.logs.subscribe(params.uuid).then (logs) ->
logs.on('line', printLine)
logs.on('error', done)
else
resin.logs.history(params.uuid).each(printLine)
promise.then ->
if options.tail
resin.logs.subscribe(params.uuid).then (logs) ->
logs.on('line', printLine)
logs.on('error', done)
.catch(done)
promise.catch(done)