Accessing context within custom logger? #4001
SantoJambit
started this conversation in
Docs Discussion
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I can't find any docs on how to access the context within a custom logger.
I've searched for other issues but couldn't find any. Could it be that this basic functionality is not supported and no-one needed it before?
Use-case:
I have set up a context factory, which provides all of my resolvers with a log instance of pino containing information about the request (a unique id most importantly).
I'd like to be able to access that log instance from within the custom logger interface provided to graphql-yoga. Or at the very least access the request-id, so that I can find all logs related to a specific request.
Does anyone have another approach to log this kind of information? I guess I could wrap all my resolvers with try/catch blocks and extend the error with a custom property containing the request id, but that seems like an overly complex solution.
Beta Was this translation helpful? Give feedback.
All reactions