Socket
Socket
Sign inDemoInstall

zetta-device-log-stream

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

zetta-device-log-stream

Creates a log-messages stream on your zetta device. Will intercept user logs and publish them on this stream.


Version published
Maintainers
1
Weekly downloads
1
decreased by-66.67%
Install size
2.76 kB

Weekly downloads

Readme

Source

Zetta device log stream

Want user defined log messages streaming from your zetta device? Look no further!

This module will pusblish user logs down their own stream that you can enable or disable at your leisure.

Usage


var Device = require('zetta-device');
var util = require('util');
var createLogStream = require('zetta-device-log-stream');

var Led = module.exports = function() {
  Device.call(this);
}
util.inherits(Led, Device);

Led.prototype.init = function(config) {
  var self = this;
  config
    .type('led')
    .name('test-led')
    .state('off')
    .when('off', { allow: ['turn-on'] })
    .when('on', { allow: ['turn-off'] })
    .map('turn-on', function(cb) {
      self.state = 'on'; 
      self.warn('Turning on!');
      cb();
    })
    .map('turn-off', function(cb) {
      self.state = 'off';
      self.warn('Turning off!');
      cb();
    });
                    
    createLogStream(this, config);                                  
};

This stream will be added to your API response

{
  title: "log-messages",
  rel: [
  "monitor",
  "http://rels.zettajs.io/object-stream"
  ],
  href: "ws://localhost:1337/servers/test/events?topic=led%2F380cb7a2-270a-4bba-8dc8-4ae39f366a53%2Flog-messages"
}

Websocket format

This is the websocket format for your custom logs.

{"topic":"led/380cb7a2-270a-4bba-8dc8-4ae39f366a53/log-messages","timestamp":1461420879643,"data":{"level":"warn","event":"test-led-log","message":"Turning on!"}}

License

MIT

Keywords

FAQs

Last updated on 23 Apr 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc