Daily Shaarli

All links of one day in a single page.

November 17, 2022

Option to skip new line when writing to stream · Issue #70 · expressjs/morgan · GitHub
thumbnail

Hi Is there a way to set up morgan to skip adding new line when using stream option? I am combining morgan's output to winston and both are adding LF line feed which results in double new lines...I can strip out the newline when it comes...

This is how

var split = require('split');
var winston = require('winston');
winston.emitErrs = true;

var logger = new winston.Logger({
    transports: [
        new winston.transports.File({
            level: 'info',
            filename: './logs/all-logs.log',
            handleExceptions: true,
            json: true,
            maxsize: 5242880, //5MB
            maxFiles: 5,
            colorize: false
        }),
        new winston.transports.Console({
            level: 'debug',
            handleExceptions: true,
            json: false,
            colorize: true
        })
    ],
    exitOnError: false
});

module.exports = logger;
module.exports.stream = split().on('data', function (message) {
  logger.info(message);
});