Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep source/unformatted/raw sting with splat ? #94

Open
Booster2ooo opened this issue Jul 17, 2019 · 0 comments
Open

Keep source/unformatted/raw sting with splat ? #94

Booster2ooo opened this issue Jul 17, 2019 · 0 comments

Comments

@Booster2ooo
Copy link

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

Booster2ooo added a commit to Booster2ooo/logform that referenced this issue Jul 19, 2019
Added the possibility to keep track of the message and parameters before formatting/interpolation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant