next-logger icon indicating copy to clipboard operation
next-logger copied to clipboard

Is there any way to get application specific context injected into the logger mixin?

Open pixelpax opened this issue 5 months ago • 1 comments

Been smashing my head against this for a minute, but I don't understand how preloaded modules work well enough.

I'm trying to add in user-specific data to pino.

Something like:

 pino({
   mixin: () => ({
     foo: global.sharedData?.foo || "foo",

Except it seems that global is not actually shared between files executed in the next server runtime (e.g. middleware.ts) and the global found in next-logger.config.js

If it was, I could use AsyncLocalStorage, but as it is I don't actually see any way of sharing memory between them. Help!

pixelpax avatar Mar 19 '24 19:03 pixelpax

Can you give a bit more context on what you're trying to do, please? Is this something you can add to your log method invocations instead, rather than implicitly mixed in?

atkinchris avatar Mar 20 '24 12:03 atkinchris