sainsburys-tech / next-logger

JSON logging patcher for Next.js
MIT License
144 stars 14 forks source link

Export non-patched console #46

Open sambuccid opened 1 month ago

sambuccid commented 1 month ago

First of all thank you for this great library, I wouldn't be able to use Next without it.

I was wondering if it would be possible to export an unpatched version of the console when we patch it.

It would be very useful for specific edge cases where we need to output something to the console without wanting to format it.

My specific use case is with nextjs middleware. The middleware forces the use of the "browser" version of pino, and this redirects all logs to the console.

This creates nested logs where the string logged is inside a log that is then sent by pino to the console and re-wrapped by next-logger.

With access to the original unpatched version of the console it would be possible to change this so that after the logs is processed by pino in my application they are sent directly to the console without passing through next-logger.

atkinchris commented 1 month ago

What would be the most ergonomic way for you to consume this? Extra methods, or an exported originalConsole/unpatchedConsole?

sambuccid commented 1 month ago

I think an exported originalConsole might feel easier to use, but I'm not sure if it will cause any issues importing that from the next-logger config file? If that would be a problem then any other way of accessing the original console would be great anyway

On Fri, 12 Jul 2024, 08:38 Chris Atkin, @.***> wrote:

What would be the most ergonomic way for you to consume this? Extra methods, or an exported originalConsole/unpatchedConsole?

— Reply to this email directly, view it on GitHub https://github.com/sainsburys-tech/next-logger/issues/46#issuecomment-2225006030, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGMNAYW7IKRPZFL5S6Z5BZDZL6BZFAVCNFSM6AAAAABKVGJEIWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRVGAYDMMBTGA . You are receiving this because you authored the thread.Message ID: @.***>