2015-01-15 14:36:43 +00:00
|
|
|
_ = require('lodash')
|
2015-01-08 12:04:37 +00:00
|
|
|
resin = require('resin-sdk')
|
2014-11-28 16:46:24 +00:00
|
|
|
|
2015-01-09 12:42:46 +00:00
|
|
|
LOGS_HISTORY_COUNT = 200
|
2014-11-29 00:51:03 +00:00
|
|
|
|
2015-01-15 17:10:14 +00:00
|
|
|
exports.logs =
|
|
|
|
signature: 'logs <uuid>'
|
|
|
|
description: 'show device logs'
|
|
|
|
help: '''
|
|
|
|
Use this command to show logs for a specific device.
|
|
|
|
|
|
|
|
By default, the command prints all log messages and exit.
|
|
|
|
|
|
|
|
To limit the output to the n last lines, use the `--num` option along with a number.
|
|
|
|
This is similar to doing `resin logs <uuid> | tail -n X`.
|
|
|
|
|
|
|
|
To continuously stream output, and see new logs in real time, use the `--tail` option.
|
|
|
|
|
|
|
|
Note that for now you need to provide the whole UUID for this command to work correctly,
|
|
|
|
and the tool won't notice if you're using an invalid UUID.
|
|
|
|
|
|
|
|
This is due to some technical limitations that we plan to address soon.
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
$ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828
|
|
|
|
$ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828 --num 20
|
|
|
|
$ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828 --tail
|
|
|
|
'''
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
signature: 'num'
|
|
|
|
parameter: 'num'
|
|
|
|
description: 'number of lines to display'
|
|
|
|
alias: 'n'
|
|
|
|
}
|
|
|
|
{
|
|
|
|
signature: 'tail'
|
|
|
|
description: 'continuously stream output'
|
|
|
|
boolean: true
|
|
|
|
alias: 't'
|
|
|
|
}
|
|
|
|
]
|
2015-01-16 12:34:59 +00:00
|
|
|
permission: 'user'
|
|
|
|
action: (params, options, done) ->
|
2015-01-15 17:10:14 +00:00
|
|
|
resin.logs.subscribe params.uuid, {
|
|
|
|
history: options.num or LOGS_HISTORY_COUNT
|
|
|
|
tail: options.tail
|
|
|
|
}, (error, message) ->
|
|
|
|
return done(error) if error?
|
2015-02-10 19:43:39 +00:00
|
|
|
if _.isArray(message)
|
|
|
|
_.each message, (line) ->
|
|
|
|
console.log(line)
|
|
|
|
else
|
|
|
|
console.log(message)
|
2015-01-15 17:10:14 +00:00
|
|
|
return done()
|