felixheck / laabr

well-formatted, extendable pino logger for hapi.js
MIT License
50 stars 7 forks source link

Redact option is not usable #118

Open Ninerian opened 2 years ago

Ninerian commented 2 years ago

Hello thanks for this library. It is really useful.

After working a while with it, I wanted to use the redact feature of pino to remove some sensitive information from the loglines. Unfortunately I found an unwanted behavior.

In this sandbox I've added a minimal example where I both defined the redact property in the pino and hapiPino property of the laabr options. The property in the hapiPino setting is completely ignored, as the Pino instance is created inside the logger.js without passing the options to Pino. When hapi-pino is initialized, it reuses the pino instance, but is unable to inject the redact settings, as they are used at the construction of Pino.

When the property in the pino setting is enabled, an exception is thrown. This results from the redact function which returns a string, this is then passed to the prettifier function in laabr. At the validation step for the preformatter an error is thrown, as it expects an Object.

I hope this helps to find a solution for this bug.

felixheck commented 2 years ago

Thanks, Daniel for raising this issue and providing the sandbox — much appreciated. Let me delve into this issue, sounds like a fun topic. It might take a while as I'm pretty busy right now.

felixheck commented 2 years ago

In case you wanna tackle it and submit a PR: go for it 😉