mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-18 21:27:51 +00:00
Merge pull request #281 from resin-io/feat/logs-timestamp
Add timestamp to logs lines
This commit is contained in:
commit
de9297c351
@ -14,12 +14,16 @@
|
||||
permission: 'user',
|
||||
primary: true,
|
||||
action: function(params, options, done) {
|
||||
var _, promise, resin;
|
||||
var _, moment, printLine, promise, resin;
|
||||
_ = require('lodash');
|
||||
resin = require('resin-sdk');
|
||||
promise = resin.logs.history(params.uuid).each(function(line) {
|
||||
return console.log(line.message);
|
||||
});
|
||||
moment = require('moment');
|
||||
printLine = function(line) {
|
||||
var timestamp;
|
||||
timestamp = moment(line.timestamp).format('DD.MM.YY HH:mm:ss (ZZ)');
|
||||
return console.log(timestamp + " " + line.message);
|
||||
};
|
||||
promise = resin.logs.history(params.uuid).each(printLine);
|
||||
if (!options.tail) {
|
||||
return promise["catch"](done)["finally"](function() {
|
||||
return process.exit(0);
|
||||
@ -27,9 +31,7 @@
|
||||
}
|
||||
return promise.then(function() {
|
||||
return resin.logs.subscribe(params.uuid).then(function(logs) {
|
||||
logs.on('line', function(line) {
|
||||
return console.log(line.message);
|
||||
});
|
||||
logs.on('line', printLine);
|
||||
return logs.on('error', done);
|
||||
});
|
||||
})["catch"](done);
|
||||
|
@ -30,9 +30,13 @@ module.exports =
|
||||
action: (params, options, done) ->
|
||||
_ = require('lodash')
|
||||
resin = require('resin-sdk')
|
||||
moment = require('moment')
|
||||
|
||||
promise = resin.logs.history(params.uuid).each (line) ->
|
||||
console.log(line.message)
|
||||
printLine = (line) ->
|
||||
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)
|
||||
|
||||
if not options.tail
|
||||
|
||||
@ -44,7 +48,6 @@ module.exports =
|
||||
|
||||
promise.then ->
|
||||
resin.logs.subscribe(params.uuid).then (logs) ->
|
||||
logs.on 'line', (line) ->
|
||||
console.log(line.message)
|
||||
logs.on('line', printLine)
|
||||
logs.on('error', done)
|
||||
.catch(done)
|
||||
|
@ -45,6 +45,7 @@
|
||||
"columnify": "^1.5.2",
|
||||
"is-root": "^1.0.0",
|
||||
"lodash": "^3.10.0",
|
||||
"moment": "^2.10.6",
|
||||
"nplugm": "^3.0.0",
|
||||
"president": "^2.0.1",
|
||||
"prettyjson": "^1.1.3",
|
||||
|
Loading…
Reference in New Issue
Block a user