-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
document the logger #1195
Comments
@n1ru4l This is a timely issue as I was recently using Yoga with RedwoodJS and there Pino logger and had a few observations:
// Log events - useful for debugging purposes
enableIf(
logger !== false,
useLogger({
skipIntrospection: true,
logFn: (eventName, events) => {
switch (eventName) {
case 'execute-start':
case 'subscribe-start':
this.logger.debug(titleBold('Execution start'))
const {
query,
operationName,
variables,
extensions,
}: YogaInitialContext = events.args.contextValue
if (query) {
this.logger.debug(
'\n' + titleBold('Received GraphQL operation:') + '\n',
query,
)
}
if (operationName) {
this.logger.debug('\t operationName:', operationName)
}
if (variables) {
this.logger.debug('\t variables:', variables)
}
if (extensions) {
this.logger.debug('\t extensions:', extensions)
}
break
case 'execute-end':
case 'subscribe-end':
this.logger.debug(titleBold('Execution end'))
this.logger.debug('\t result:', events.result)
break
}
},
}),
In this case using the Pino logger to output NDJSON in a Netlify function
This is a Redwood debug log from the GraphQL Server ... can see a few things: 1) redaction is enabled (we hide the title as en example of log redaction), 2) we have separate keys for data, operationName, query variables etc. 3) we add a name (Pino child logger) to distinguish itself from other logging/logs sent
Suggestions (and perhaps this is a separate issue):
|
Pino with their transports is an excellent way to send logs to tools like Datadog and LogFlare. |
|
We should add better docs on the logger customization.
The text was updated successfully, but these errors were encountered: