winston-nexus

1.0.1 • Public • Published

winston-nexus

A Nexus transport for Winston 3+ that logs to a channel via webhooks.

Installation

npm install winston winston-nexus

Usage

Set up by adding

const winston = require("winston");
const {UDP, MQTT} = require("winston-nexus");
const aedes = require('aedes')({ heartbeatInterval: 1000, connectTimeout: 1000});
const server = require('net').createServer(aedes.handle);

winston.loggers.add('udpLog', {
  level: config.env === 'development' ? config.logger.level : 'info',
});


winston.loggers.add('mqttLog', {
  level: config.env === 'development' ? config.logger.level : 'info',
});

const udpLog = winston.loggers.get('udpLog');
const mqttLog = winston.loggers.get('mqttLog');

udpLog.add(new UDP({
    host: "localhost",
    port: 3030,
    protocol: "udp4",
    appName: "name-of-app"
  }));

mqttLog.add(new MQTT({
    socket: server
    appName: "name-of-app"
  }));

...

Logging

const metadata = {
  someProp: "hello",
  anotherProp: 1234,
  ...
}
udpLog.info("My udp log message", metadata);
mqttLog.info("My mqtt log message", metadata);

Package Sidebar

Install

npm i winston-nexus

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

8.02 kB

Total Files

8

Last publish

Collaborators

  • obediah