pinojs / pino

🌲 super fast, all natural json logger
http://getpino.io
MIT License
13.96k stars 861 forks source link

Forbid using default log levels when `useOnlyCustomLevels: true` #1998

Closed chernodub closed 2 weeks ago

chernodub commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 https://github.com/pinojs/pino/pull/1999 :)