winstonjs/logform

Keep source/unformatted/raw sting with splat ?

Opened this issue · 0 comments

Hello,

I'm suggesting to add an option to the splat transformer that would allow to keep the source/original message (before formatting) in the metadata.

Current behavior:

const logger = winston.createLogger({
	level: 'info',
	format: winston.format.combine(
		winston.format.splat(),
		winston.format.logstash()
	),
	transports: [
		new winston.transports.Console()
	]
});

logger.info('hello %s', 'world', { foo: 'bar'}  );
//> {"@message":"hello world","@fields":{"level":"info","foo":"bar"}}

Desired behavior

const logger = winston.createLogger({
	level: 'info',
	format: winston.format.combine(
		winston.format.splat({ source: 'raw', arguments: 'params'}),
		winston.format.logstash()
	),
	transports: [
		new winston.transports.Console()
	]
});

logger.info('hello %s', 'world', { foo: 'bar'}  );
//> {"@message":"hello world","@fields":{"level":"info","raw":"hello %s","params":["world"],"foo":"bar"}}

I hope this suggestion will be accepted, it would be very useful when working with logging systems like the Elastic stack.

Best regards