resin-device-logs v3.2.1
resin-device-logs
Resin.io device logs utilities.
Role
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.
Installation
Install resin-device-logs by running:
$ npm install --save resin-device-logsDocumentation
- logs
- .subscribe(pubnubKeys, device) ⇒ EventEmitter
- .history(pubnubKeys, device, [options]) ⇒ Promise.<Array.<Object>>
- .historySinceLastClear(pubnubKeys, device, [options]) ⇒ Promise.<Array.<Object>>
- .clear(pubnubKeys, device) ⇒ Promise
- .getLastClearTime(pubnubKeys, device) ⇒ Promise.<number>
logs.subscribe(pubnubKeys, device) ⇒ EventEmitter
This function emits various events:
line: When a log line arrives, passing an object as an argument.clear: When theclearrequest is published (see theclearmethod)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()logs.history(pubnubKeys, device, options) ⇒ 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)logs.historySinceLastClear(pubnubKeys, device, options) ⇒ 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)logs.clear(pubnubKeys, device) ⇒ 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 |
logs.getLastClearTime(pubnubKeys, 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 |
Support
If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.
Tests
Run the test suite by doing:
$ npm testContribute
- Issue Tracker: github.com/resin-io/resin-device-logs/issues
- Source Code: github.com/resin-io/resin-device-logs
Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:
$ npm run lintLicense
The project is licensed under the Apache 2.0 license.

