Skip to content

Commit cd7d2b4

Browse files
schettnNico Schett
andauthored
feat: add option to disable logger to config (#104)
* feat: add option to disable logger to config * Create chatty-hornets-develop.md --------- Co-authored-by: Nico Schett <[email protected]>
1 parent f4f3dca commit cd7d2b4

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@getcronit/pylon": patch
3+
---
4+
5+
feat: add option to disable logger to config

packages/pylon/src/app/handler/pylon-handler.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import {
66
JSONResolver
77
} from 'graphql-scalars'
88
import {createSchema, createYoga} from 'graphql-yoga'
9+
import {logger} from 'hono/logger'
910

1011
import {useDisableIntrospection} from '@envelop/disable-introspection'
1112
import {readFileSync} from 'fs'
1213
import path from 'path'
13-
import {PylonConfig} from '../..'
14+
import {app, PylonConfig} from '../..'
1415
import {Context, getContext} from '../../context'
1516
import {resolversToGraphQLResolvers} from '../../define-pylon'
1617
import {useSentry} from '../envelop/use-sentry'
@@ -153,6 +154,10 @@ export const handler = (options: PylonHandlerOptions) => {
153154
schema
154155
})
155156

157+
if (config?.logger !== false) {
158+
app.use('*', logger())
159+
}
160+
156161
const handler = async (c: Context): Promise<Response> => {
157162
let executionContext: Context['executionCtx'] | {} = {}
158163

packages/pylon/src/app/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {sentry} from '@hono/sentry'
22
import {Hono} from 'hono'
3-
import {logger} from 'hono/logger'
43

54
import {asyncContext, Env} from '../context'
65

@@ -20,8 +19,6 @@ app.use('*', async (c, next) => {
2019
})
2120
})
2221

23-
app.use('*', logger())
24-
2522
app.use((c, next) => {
2623
// @ts-ignore
2724
c.req.id = crypto.randomUUID()

packages/pylon/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type PylonConfig = Pick<
2323
'plugins'
2424
> & {
2525
graphiql?: boolean | ((c: Context) => boolean)
26+
logger?: boolean
2627
}
2728

2829
export type ID = string & {readonly brand?: unique symbol}

0 commit comments

Comments
 (0)