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

Forbid using default log levels when useOnlyCustomLevels: true #1998

Open
chernodub opened this issue Jul 1, 2024 · 2 comments · May be fixed by #1999
Open

Forbid using default log levels when useOnlyCustomLevels: true #1998

chernodub opened this issue Jul 1, 2024 · 2 comments · May be fixed by #1999

Comments

@chernodub
Copy link

Currently, pino's TS declaration allows using default log levels when useOnlyCustomLevels is true. This following code will result in a runtime error:

import { pino } from 'pino';

const logger = pino({
  customLevels: { customInfo: 10 },
  useOnlyCustomLevels: true,
});

logger.info('123'); // TS should warn here ?
logger.customInfo('123'); // should work fine

Expected behavior:

import { pino } from 'pino';

const logger = pino({
  customLevels: { customInfo: 10 },
  useOnlyCustomLevels: true,
});

logger.info('123'); // TS errors here
logger.customInfo('123'); // works fine
@mcollina
Copy link
Member

mcollina commented Jul 2, 2024

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests. We use tsd for the types.

@chernodub
Copy link
Author

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests. We use tsd for the types.

Yep, already submitted the PR #1999 :)

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

Successfully merging a pull request may close this issue.

2 participants