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

Consider simplifying log function interface #64

Open
gajus opened this issue Aug 11, 2022 · 2 comments
Open

Consider simplifying log function interface #64

gajus opened this issue Aug 11, 2022 · 2 comments
Milestone

Comments

@gajus
Copy link
Owner

gajus commented Aug 11, 2022

There is no real difference between:

log.info({time: 1}, 'foo');

and

log.child({time: 1}).info('foo');

If we dropper the former API interface, it would make it easier to avoid mistakes such as attempting to pass context as printf parameters.

Great suggestion by @mikeroelens.

The only concern here is that it is a major breaking change with no easy way to add backwards compatibility. I doubt it will be implemented due to the latter reason, but worth considering how we could promote this pattern more.

@gajus gajus added this to the v8 milestone Aug 11, 2022
@eMerzh
Copy link

eMerzh commented May 1, 2023

I know it might be hard to break the compatibilty like that,

but to be honest, it's one of the surprising choice made in roarr...
i feel other logging libs will start with the message, then add the context ....
so i would be in favor of some kind of solution that make that clearer, even if it break the API

@glensc
Copy link

glensc commented Oct 26, 2023

it might have come from developer's prior use of Pino.

I found this odd pattern too when using pino, so I had to write a wrapper that translates:

  • "string", ...args

to

  • { args }, "string"

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

3 participants