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

Drop support for printf style logging because once again i deployed logger.info(msg, obj) instead of logger.info(obj, msg) to prod and cant debug prod. #2033

Open
Raynos opened this issue Aug 21, 2024 · 2 comments

Comments

@Raynos
Copy link

Raynos commented Aug 21, 2024

Would you accept a pull request for a breaking change where we drop varags on the LogFn and do not support printf style logging.

// this is fine
logger.info('a message')
// this is good. I wont bike shed about how the arguments should be swapped like bunyan and the rest.
logger.info({
  something: 'happened'
}, 'a more descriptive image.

// This is horrible.
logger.info('oh hi %s', 'bye')

The issue I'm running into is that when I do the following

logger.info('a msg', { ... })

it's not a typescript error, because its technically an invalid printf expression and the vargs of ...any[] in the type signature makes the pino api basically untyped.

I want to make it harder for me to deploy broken log statements to prod when i swapped the arguments by accident and didnt catch it in review.

I'm happy to do the pull request, and of course it would be a major version.

@jsumners
Copy link
Member

Sounds like a self inflicted issue. I recommend using https://getpino.io/#/docs/api?id=logmethod to standardize your logger instance to the way you like it.

@Raynos
Copy link
Author

Raynos commented Aug 21, 2024

That hook doesn't help at all with the typescript definitions. Currently i cast the logger to an interface with a stricter type definition. But really it's a footgun for everyone.

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

2 participants