1.0.0 • Published 7 years ago

winston-mqtt v1.0.0

Weekly downloads
24
License
ISC
Repository
github
Last release
7 years ago

winston-mqtt

A Winston transport for logging via MQTT

This transport will log to a given topic in JSON format.

Installation

npm install winston-mqtt --save

Usage

/**
 * Requiring `winston-mqtt` will expose
 * `winston.transports.MqttTransport`
 */
require('winston-mqtt').MqttTransport;

winston.add(winston.transports.MqttTransport, {
   name: 'source-name',
   topic: 'mqtt-topic',
   host: 'mqtt://localhost:1883',
   requestTracer: {
     instance: myRequestObject,
     property: 'requestId'
   }
});

The MqttTransport takes the following options. 'name' and 'topic' is required:

  • name: Transport instance identifier. This will be embeded into the JSON data logged to the MQTT topic.
  • topic: The MQTT topic to use for logging.
  • level: Level of messages that this transport should log, defaults to 'info'.
  • host: The MQTT host address, defaults to: mqtt://localhost:1883
  • requestTracer.instance: If you want to trace a specific request using the continuation-local-storage module
  • requestTracer.property: Property of the request id in your object