Open marceloverdijk opened 2 months ago
Note I'm now doing this: https://github.com/pinojs/pino/issues/1969#issuecomment-2311788254
But above questions are still relevant.
We are not testing against Cloudflare Workers, so this is essentially unsupported right now on that platform.
Seconding that this is not specific to Cloudflare Workers, the pino({base: {foo: 'bar'}})
feature does not appear to work/be supported in browser mode. Nor does pino({formatters: {bindings: () => {bindings.foo = "bar"; return bindings;} }})
EDIT: Code Sandbox link to demonstrate, little clunky to find the JS console:
Would you like to send a Pull Request to address this issue? Remember to add unit tests.
If I find the time soon, I sure will! Thanks 😄
It looks like formatters.log
basically supports "dynamic bindings at log time" which is the functionality I care about, so I'm happy to say this is all good! Thanks for all your work on this library 👍
Codesandbox: https://codesandbox.io/p/sandbox/elastic-haze-997gtz
Hi,
I'm trying to use pino (browser) with Cloudflare Workers. This is my config do far:
which outputs the log messages like below and is a good start:
logger.debug('Loading customer with id=%s', 'jane-doe')
:logger.trace('Fetching customer with id=%s from database', 'jane-doe')
:(1)
Although the
level
is defined astrace
, calls tologger.trace(..)
are not being logged... is that expected behaviour with pino/browser?Now when I add the custom
write
option to the config, trace is being outputted...logger.debug('Loading customer with id=%s', 'jane-doe')
:logger.trace('Fetching customer with id=%s from database', 'jane-doe')
:so with a custom
write
option it seems to pick uptrace
logs...(2)
When creating the logger I used the following
base
option to set a context requestId...but this is never logged, nor available in the
write: (o)
object... is it possible to use a context with pino/browser?Note I also looked into logMethod but that does not seem to be invoked by pino/browser at all.
Now when I create a child logger and pass the
requestId
it does work:gives:
{"time":"2024-08-26T20:54:40.750Z","level":"DEBUG","requestId":"ec1eeec6-6dc7-45a8-872e-19d360844d80","msg":"Loading customer with id=jane-doe"}
But I do not need a child logger, is there a way to pass this context directly to the (parent) logger?