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-logs
Documentation
- 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>
- .subscribe(pubnubKeys, device) ⇒
EventEmitter
logs.subscribe(pubnubKeys, device) ⇒ This function emits various events:
line
: When a log line arrives, passing an object as an argument.clear
: When theclear
request is published (see theclear
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 = logssubscribe subscribe_key: '...' publish_key: '...' device deviceLogson 'line' line -> console console console deviceLogson 'error' error -> throw error deviceLogson 'clear' -> console
Promise.<Array.<Object>>
logs.history(pubnubKeys, device, [options]) ⇒ 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
logshistory subscribe_key: '...' publish_key: '...' device -> for line in lines console console console
Promise.<Array.<Object>>
logs.historySinceLastClear(pubnubKeys, device, [options]) ⇒ 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
logshistorySinceLastClear subscribe_key: '...' publish_key: '...' device -> for line in lines console console console
Promise
logs.clear(pubnubKeys, device) ⇒ 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>
logs.getLastClearTime(pubnubKeys, device) ⇒ 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 test
Contribute
- 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 lint
License
The project is licensed under the Apache 2.0 license.