allow slog logs to be disabled/configured
This commit is contained in:
parent
e57c930f0c
commit
6e8d7ef1b8
|
@ -1,3 +1,6 @@
|
|||
PRISMA_SLOW_LOGS_MS=
|
||||
GRAPHQL_SLOW_LOGS_MS=
|
||||
|
||||
############################################################################
|
||||
# OPTIONAL SECRETS #
|
||||
# put these in .env.local, and don't commit them to git #
|
||||
|
|
|
@ -17,3 +17,5 @@ NEXT_PUBLIC_LONG_POLL_INTERVAL=60000
|
|||
NEXT_PUBLIC_EXTRA_LONG_POLL_INTERVAL=300000
|
||||
NEXT_PUBLIC_URL=https://stacker.news
|
||||
TOR_PROXY=http://127.0.0.1:7050/
|
||||
PRISMA_SLOW_LOGS_MS=50
|
||||
GRAPHQL_SLOW_LOGS_MS=50
|
|
@ -6,7 +6,7 @@ const prisma = global.prisma || (() => {
|
|||
log: [{ level: 'query', emit: 'event' }, 'warn', 'error']
|
||||
})
|
||||
prisma.$on('query', (e) => {
|
||||
if (e.duration > 50) {
|
||||
if (process.env.PRISMA_SLOW_LOGS_MS && e.duration > process.env.PRISMA_SLOW_LOGS_MS) {
|
||||
console.log('Query: ' + e.query)
|
||||
console.log('Params: ' + e.params)
|
||||
console.log('Duration: ' + e.duration + 'ms')
|
||||
|
|
|
@ -26,7 +26,7 @@ const apolloServer = new ApolloServer({
|
|||
return (error, result) => {
|
||||
const end = process.hrtime.bigint()
|
||||
const ms = (end - start) / 1000000n
|
||||
if (ms > 50) {
|
||||
if (process.env.GRAPHQL_SLOW_LOGS_MS && ms > process.env.GRAPHQL_SLOW_LOGS_MS) {
|
||||
console.log(`Field ${info.parentType.name}.${info.fieldName} took ${ms}ms`)
|
||||
}
|
||||
if (error) {
|
||||
|
|
Loading…
Reference in New Issue