winstonjs/logform

Timestamp at the end instead of beginning

antonymarion opened this issue · 0 comments

New logform version results in timestamp at the end of the line for winston with the following example code

const winston = require('winston');

class TimestampFirst {
    constructor(enabled = true) {
        this.enabled = enabled;
    }
    transform(obj) {
        if (this.enabled) {
            return Object.assign({
                timestamp: obj.timestamp
            }, obj);
        }
        return obj;
    }
}

var myFormat = winston.format.combine(
    winston.format.timestamp({
        format: 'YYYY-MM-DD HH:mm:ss.SSS'
    }),
    new TimestampFirst(true),
    winston.format.json()
);

winstonLogger = winston.createLogger();
winstonLogger.configure({
    level: 'info',
    format: myFormat,
    transports: [
        new winston.transports.Console(),
    ]
});


winstonLogger.info('hello', {
    message: 'test'
});