Skip to content

Commit

Permalink
fix(api): error logging
Browse files Browse the repository at this point in the history
I got some Pino internal errors before, and it looks like `this` is not
bound correctly, so using `.bind` should work around that.

Got some help from here: https://www.github.com/pinojs/pino/issues/1687
  • Loading branch information
JoosepAlviste committed Oct 4, 2023
1 parent a8fa614 commit cea9003
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions apps/api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@ export const yoga = createYoga<{
}),
],
logging: {
debug: (...args) => args.forEach(log.debug),
info: (...args) => args.forEach(log.info),
warn: (...args) => args.forEach(log.warn),
error: (...args) => {
console.log('error!', args)
return args.forEach(log.error)
},
debug: (...args) => args.forEach(log.debug.bind(log)),
info: (...args) => args.forEach(log.info.bind(log)),
warn: (...args) => args.forEach(log.warn.bind(log)),
error: (...args) => args.forEach(log.error.bind(log)),
},
schema,
context: async (ctx): Promise<Context> => {
Expand Down

0 comments on commit cea9003

Please sign in to comment.