3.2.1 • Published 6 years ago

resin-device-logs v3.2.1

Weekly downloads
19
License
Apache-2.0
Repository
github
Last release
6 years ago

resin-device-logs

npm version dependencies Build Status Build status

Join our online chat at Gitter chat

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

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

ParamTypeDescription
pubnubKeysObjectPubNub keys
deviceObjectdevice

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

ParamTypeDescription
pubnubKeysObjectPubNub keys
deviceObjectdevice
optionsObjectother 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

ParamTypeDescription
pubnubKeysObjectPubNub keys
deviceObjectdevice
optionsObjectother 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

ParamTypeDescription
pubnubKeysObjectPubNub keys
deviceObjectdevice

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

ParamTypeDescription
pubnubKeysObjectPubNub keys
deviceObjectdevice

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

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.

3.2.1

6 years ago

3.2.0

6 years ago

3.1.2

7 years ago

3.1.1

7 years ago

3.1.0

7 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.1.0

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.0

9 years ago