A transport to use with winston logging library to publish logs on a pubsub channel on Redis.
There are other transports available for Redis, this one uses ioredis. So, if you already have it as a dependency in your project you won't need to introduce another redis package just to log.
npm install winston-ioredis-transport
JavaScript:
const Redis = require('ioredis');
const winston = require('winston');
const {WinstonIORedisTransport} = require('winston-ioredis-transport');
let redis = new Redis();
let logger = winston.createLogger({
transports: [
new WinstonIORedisTransport({redis, channel: 'logs'})
]
});
logger.info('my new message', {abc: 123, ts: new Date(), colour: "purple"});
TypeScript:
import Redis from 'ioredis';
import winston from 'winston';
import {WinstonIORedisTransport} from 'winston-ioredis-transport';
let redis = new Redis();
let logger = winston.createLogger({
transports: [
new WinstonIORedisTransport({redis, channel: 'logs'})
]
});
logger.info('my new message', {abc: 123, ts: new Date(), colour: "purple"});
The tests are written in Gherkin with cucumber and Sinon.js
npm test
Author: Faramarz Salehpour