Typing of logger field on Request is misleading in case of ignored routes
- Dominant language
- JavaScript
- Stars
- 147
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
### Runtime
node.js
### Runtime version
18
### Module version
12.2.0
### Last module version without issue
_No response_
### Used with
hapi application
### Any other relevant information
_No response_
### What are you trying to achieve or the steps to reproduce?
In certain cases I would like to access pino logger specific attributes and functions (e.g. `bindings()`) even when the route accessing `logger` might later be ignored using any of the `ignoreX` options.
### What was the result you got?
TypeErrors such as `logger.bindings is not a function` requiring me to build checks around the presence of methods such as `bindings`.
### What result did you expect?
I was expecting the logger instance on the request to always be of type pino.Logger, but it might be the much simpler `nullLogger` instance from [`abstract-logging`](https://www.npmjs.com/package/abstract-logging) that is used in case of ignored routes.
Ideally the nullLogger should be extended to implement all methods of the pino.Logger interface, alternatively the typings in `hapi-pino` should reflect that the `logger` might be missing some of the methods in `pino.Logger`.
Contributor guide
Research direction
Start by locating the request logger typing and the nullLogger used for ignored routes. Reproduce an ignored route with hapi on Node 18 and compare its available methods with pino.Logger; done means the chosen fix makes the runtime behavior and typings agree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, observability-sre
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100