This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

resin-device-logs

3.2.1 • Public • Published

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

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 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.

Readme

Keywords

Package Sidebar

Install

npm i resin-device-logs

Weekly Downloads

1

Version

3.2.1

License

Apache-2.0

Last publish

Collaborators

  • balena.io