← Projects

Installation

npm install @seanvelasco/winston-mqtt

Usage

import winston from 'winston'
import MQTT from '@seanvelasco/winston-mqtt'

const mqttOptions = {
    host: '127.0.0.1',
    port: 1883,
    clientId: '',
    username: '',
    password: '',
}

const logger = winston.createLogger({
    level: 'info',
    transports: [
        new winston.transports.File({ filename: 'info.log', level: 'info' }),
        new MQTT({ ...mqttOptions, topic: 'diagnostics/info', level: 'info' }),
    ]
})

Features

Include level, log message, and meta properties in the message as JSON payload

Pass includeMeta: true when instantiating the MQTT transport to include the level, message, and meta properties in the message as JSON payload.

Limitations

In the future