Resin.io device logs utilities.
The intention of this module is to provide low level access to Resin.io device logs.
THIS MODULE IS LOW LEVEL AND IS NOT MEANT TO BE USED BY END USERS DIRECTLY.
Unless you know what you're doing, use the Resin SDK instead.
Install resin-device-logs
by running:
$ npm install --save resin-device-logs
EventEmitter
Promise.<Array.<Object>>
Promise.<Array.<Object>>
Promise
Promise.<number>
EventEmitter
This function emits various events:
line
: When a log line arrives, passing an object as an argument.clear
: When the clear
request is published (see the clear
method)error
: When an error occurs, passing an error code as an argument.The object returned by this function also contains the following functions:
.unsubscribe()
: Unsubscribe from the device channel.Kind: static method of logs
Summary: Subscribe to device logs
Returns: EventEmitter
- logs
Access: public
Param | Type | Description |
---|---|---|
pubnubKeys | Object |
PubNub keys |
device | Object |
device |
Example
deviceLogs = logs.subscribe
subscribe_key: '...'
publish_key: '...'
,
device
deviceLogs.on 'line', (line) ->
console.log(line.message)
console.log(line.isSystem)
console.log(line.timestamp)
deviceLogs.on 'error', (error) ->
throw error
deviceLogs.on 'clear', ->
console.clear()
Promise.<Array.<Object>>
Kind: static method of logs
Summary: Get device logs history
Returns: Promise.<Array.<Object>>
- device logs history
Access: public
Param | Type | Description |
---|---|---|
pubnubKeys | Object |
PubNub keys |
device | Object |
device |
[options] | Object |
other options supported by https://www.pubnub.com/docs/nodejs-javascript/api-reference#history |
Example
logs.history
subscribe_key: '...'
publish_key: '...'
,
device
.then (lines) ->
for line in lines
console.log(line.message)
console.log(line.isSystem)
console.log(line.timestamp)
Promise.<Array.<Object>>
Kind: static method of logs
Summary: Get device logs history after the most recent clear
Returns: Promise.<Array.<Object>>
- device logs history
Access: public
Param | Type | Description |
---|---|---|
pubnubKeys | Object |
PubNub keys |
device | Object |
device |
[options] | Object |
other options supported by https://www.pubnub.com/docs/nodejs-javascript/api-reference#history |
Example
logs.historySinceLastClear
subscribe_key: '...'
publish_key: '...'
,
device
.then (lines) ->
for line in lines
console.log(line.message)
console.log(line.isSystem)
console.log(line.timestamp)
Promise
Kind: static method of logs
Summary: Clear device logs history
Returns: Promise
- - resolved witht he PubNub publish response
Access: public
Param | Type | Description |
---|---|---|
pubnubKeys | Object |
PubNub keys |
device | Object |
device |
Promise.<number>
Kind: static method of logs
Summary: Get the most recent device logs history clear time
Returns: Promise.<number>
- timetoken
Access: public
Param | Type | Description |
---|---|---|
pubnubKeys | Object |
PubNub keys |
device | Object |
device |
If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.
Run the test suite by doing:
$ npm test
Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:
$ npm run lint
The project is licensed under the Apache 2.0 license.