next-logger
next-logger copied to clipboard
Is there any way to get application specific context injected into the logger mixin?
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!
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?