Skip to content
New issue

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

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

Already on GitHub? # to your account

Forbid using default log levels when useOnlyCustomLevels: true #1998

Closed
chernodub opened this issue Jul 1, 2024 · 3 comments · Fixed by #1999
Closed

Forbid using default log levels when useOnlyCustomLevels: true #1998

chernodub opened this issue Jul 1, 2024 · 3 comments · Fixed by #1999

Comments

@chernodub
Copy link
Contributor

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
Contributor 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 :)

mcollina added a commit that referenced this issue Aug 21, 2024
#1999)

* feat(types): forbid using default log fn when custom only used

* test: move types test to tsd file

* feat: allow overriding default levels

---------

Co-authored-by: Matteo Collina <hello@matteocollina.com>
alexandresoro pushed a commit to alexandresoro/ouca that referenced this issue Sep 4, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [pino](https://getpino.io) ([source](https://github.com/pinojs/pino)) | dependencies | minor | [`9.3.2` -> `9.4.0`](https://renovatebot.com/diffs/npm/pino/9.3.2/9.4.0) |

---

### Release Notes

<details>
<summary>pinojs/pino (pino)</summary>

### [`v9.4.0`](https://github.com/pinojs/pino/releases/tag/v9.4.0)

[Compare Source](pinojs/pino@v9.3.2...v9.4.0)

#### What's Changed

-   Drop failing pnpm tests by [@&#8203;mcollina](https://github.com/mcollina) in pinojs/pino#2015
-   Add bun plugin link to docs by [@&#8203;vktrl](https://github.com/vktrl) in pinojs/pino#2016
-   build(deps-dev): bump [@&#8203;types/node](https://github.com/types/node) from 20.14.13 to 22.0.0 by [@&#8203;dependabot](https://github.com/dependabot) in pinojs/pino#2017
-   docs: Update transports.md by [@&#8203;Imgodmaoyouknow](https://github.com/Imgodmaoyouknow) in pinojs/pino#2027
-   build(deps-dev): bump [@&#8203;yao-pkg/pkg](https://github.com/yao-pkg/pkg) from 5.12.0 to 5.12.1 by [@&#8203;dependabot](https://github.com/dependabot) in pinojs/pino#2031
-   feat(types): forbid using default log fn when custom only used ([#&#8203;1998](pinojs/pino#1998)) by [@&#8203;chernodub](https://github.com/chernodub) in pinojs/pino#1999
-   feat: accept level in capitals by [@&#8203;balaji-atoa](https://github.com/balaji-atoa) in pinojs/pino#2034

#### New Contributors

-   [@&#8203;vktrl](https://github.com/vktrl) made their first contribution in pinojs/pino#2016
-   [@&#8203;Imgodmaoyouknow](https://github.com/Imgodmaoyouknow) made their first contribution in pinojs/pino#2027
-   [@&#8203;chernodub](https://github.com/chernodub) made their first contribution in pinojs/pino#1999
-   [@&#8203;balaji-atoa](https://github.com/balaji-atoa) made their first contribution in pinojs/pino#2034

**Full Changelog**: pinojs/pino@v9.3.2...v9.4.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC42NC4xIiwidXBkYXRlZEluVmVyIjoiMzguNjQuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->

Reviewed-on: https://git.tristess.app/alexandresoro/ouca/pulls/79
Reviewed-by: Alexandre Soro <code@soro.dev>
Co-authored-by: renovate <renovate@git.tristess.app>
Co-committed-by: renovate <renovate@git.tristess.app>
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants