winston-mqtt

Winston MQTT transport

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
winston-mqtt
1.0.06 years ago6 years agoMinified + gzip package size for winston-mqtt in KB

Readme

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