From cea9003df8bf5a71245a771f7f2a0237b6b8ac5d Mon Sep 17 00:00:00 2001 From: Joosep Alviste Date: Wed, 4 Oct 2023 19:54:38 +0300 Subject: [PATCH] fix(api): error logging 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 --- apps/api/src/server.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/api/src/server.ts b/apps/api/src/server.ts index 6a1fa9bc..3cfaea7f 100644 --- a/apps/api/src/server.ts +++ b/apps/api/src/server.ts @@ -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 => {