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

[proposal] Document logger field + add it to API #125

Open
laSinteZ opened this issue Apr 10, 2021 · 1 comment
Open

[proposal] Document logger field + add it to API #125

laSinteZ opened this issue Apr 10, 2021 · 1 comment

Comments

@laSinteZ
Copy link
Contributor

In the documentation, it is noted that there's an option "logger" which can be passed

logger: pino-http can reuse a pino instance if passed with the logger property

However, it is not entirely correct: according to the code, pino instance isn't reused, but a child is created from this instance. This way, for example, it is not possible to change log level in the runtime. (since changing log level on the "root" instance doesn't change the child's log level). Also, there's no way (according to the documentation) to change middleware's logger level in the runtime (since it's not documented how logger is exposed).

Example:

const pino = require("pino");
const pinoHttp = require("pino-http");

const pinoLogger = pino();
middleware = pinoHttp({ logger: pinoLogger });
pinoLogger.level = "warn" // Does not change middleware's log level

This can be bypassed by using the middleware.logger field, like this:

const pinoHttp = require("pino-http");
middleware = pinoHttp();
middleware.logger.level = "warn" // Does change logger level

My concern is, however, that this field isn't part of an API, since it is not documented. So, it can be "removed" or renamed in any version w/o notice.

Can we declare this .logger instance as a part of public API and document it (I can help with documentation, if needed).

@mcollina
Copy link
Member

Go ahead with the PR!

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

No branches or pull requests

2 participants