logger code mods v0.28
This commit is contained in:
@@ -11,3 +11,8 @@ DATABASE_URL=file:./dev.db
|
|||||||
|
|
||||||
# disables Prisma CLI update notifier
|
# disables Prisma CLI update notifier
|
||||||
PRISMA_HIDE_UPDATE_MESSAGE=true
|
PRISMA_HIDE_UPDATE_MESSAGE=true
|
||||||
|
|
||||||
|
# Option to override the current environment's default api-side log level
|
||||||
|
# See: https://redwoodjs.com/docs/logger for level options:
|
||||||
|
# trace | info | debug | warn | error | silent
|
||||||
|
# LOG_LEVEL=debug
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
# DATABASE_URL=file:./dev.db
|
# DATABASE_URL=file:./dev.db
|
||||||
# BINARY_TARGET=native
|
# BINARY_TARGET=native
|
||||||
|
# LOG_LEVEL=debug
|
||||||
|
|||||||
@@ -3,4 +3,19 @@
|
|||||||
|
|
||||||
import { PrismaClient } from '@prisma/client'
|
import { PrismaClient } from '@prisma/client'
|
||||||
|
|
||||||
export const db = new PrismaClient()
|
import { emitLogLevels, handlePrismaLogging } from '@redwoodjs/api/logger'
|
||||||
|
|
||||||
|
import { logger } from './logger'
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instance of the Prisma Client
|
||||||
|
*/
|
||||||
|
export const db = new PrismaClient({
|
||||||
|
log: emitLogLevels(['info', 'warn', 'error']),
|
||||||
|
})
|
||||||
|
|
||||||
|
handlePrismaLogging({
|
||||||
|
db,
|
||||||
|
logger,
|
||||||
|
logLevels: ['info', 'warn', 'error'],
|
||||||
|
})
|
||||||
|
|||||||
17
api/src/lib/logger.js
Normal file
17
api/src/lib/logger.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { createLogger } from '@redwoodjs/api/logger'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a logger with RedwoodLoggerOptions
|
||||||
|
*
|
||||||
|
* These extend and override default LoggerOptions,
|
||||||
|
* can define a destination like a file or other supported pin log transport stream,
|
||||||
|
* and sets where or not to show the logger configuration settings (defaults to false)
|
||||||
|
*
|
||||||
|
* @param RedwoodLoggerOptions
|
||||||
|
*
|
||||||
|
* RedwoodLoggerOptions have
|
||||||
|
* @param {options} LoggerOptions - defines how to log, such as pretty printing, redaction, and format
|
||||||
|
* @param {string | DestinationStream} destination - defines where to log, such as a transport stream or file
|
||||||
|
* @param {boolean} showConfig - whether to display logger configuration on initialization
|
||||||
|
*/
|
||||||
|
export const logger = createLogger({})
|
||||||
Reference in New Issue
Block a user