Skip to content

Typing of logger field on Request is misleading in case of ignored routes #186

@nlochschmidt

Description

@nlochschmidt

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 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions