diff --git a/bun.lockb b/bun.lockb index 8939e69..ff51ac9 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 73944a9..be83b8c 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,8 @@ "@tailwindcss/typography": "^0.5.15", "graphql": "^16.9.0", "graphql-yoga": "^5.10.4", + "pino": "^9.5.0", + "pino-pretty": "^13.0.0", "storybook-dark-mode": "^4.0.2" } } diff --git a/src/lib/logger/index.ts b/src/lib/logger/index.ts new file mode 100644 index 0000000..38ed4aa --- /dev/null +++ b/src/lib/logger/index.ts @@ -0,0 +1,23 @@ +import { type YogaLogger } from 'graphql-yoga'; +import pino from 'pino'; + +export const logger = pino(); + +export const yogaLogger: YogaLogger = { + debug(...args) { + // @ts-expect-error types dont match + logger.debug(...args); + }, + info(...args) { + // @ts-expect-error types dont match + logger.info(...args); + }, + warn(...args) { + // @ts-expect-error types dont match + logger.warn(...args); + }, + error(...args) { + // @ts-expect-error types dont match + logger.error(...args); + } +}; \ No newline at end of file diff --git a/src/lib/yoga/index.ts b/src/lib/yoga/index.ts index 835252e..274b44f 100644 --- a/src/lib/yoga/index.ts +++ b/src/lib/yoga/index.ts @@ -1,3 +1,4 @@ +import { yogaLogger } from '$lib/logger'; import { Schema } from '$lib/pothos'; import type { RequestEvent } from '@sveltejs/kit'; import { createYoga } from 'graphql-yoga'; @@ -6,5 +7,6 @@ export const Yoga = createYoga({ schema: Schema, graphqlEndpoint: '/api/graphql', // Let Yoga use sveltekit's Response object - fetchAPI: { Response } + fetchAPI: { Response }, + logging: yogaLogger }); \ No newline at end of file