Skip to content

Feat/logger#534

Open
HaakonMikalsen wants to merge 2 commits into
mainfrom
feat/logger
Open

Feat/logger#534
HaakonMikalsen wants to merge 2 commits into
mainfrom
feat/logger

Conversation

@HaakonMikalsen

Copy link
Copy Markdown
Contributor

Add logging support
Add automatic logging to database events

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds application logging support for Prisma database events and updates the runtime configuration so logs can be written to rotating log files.

Changes:

  • Added Prisma $on(...) handlers in the shared Prisma client to emit query/error/info/warn events to the app logger.
  • Exposed LOG_TO_FILE into the Docker Compose environment so file logging can be enabled in containers.
  • Updated default logging environment values (default LOG_LEVEL, enabled file logging, and updated log retention format).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/prisma/client.ts Adds Prisma event listeners and routes Prisma logs through the shared Winston logger.
docker-compose.base.yml Passes LOG_TO_FILE through to the container environment.
.env.default Updates default logging configuration values (level, file logging, retention).

Comment thread src/prisma/client.ts
})

prisma.$on('query', (e) => {
if (e.query.includes('SELECT')) { // Sets select query to debug as it generates an unreasonable amount of logs
Comment thread src/prisma/client.ts
Comment on lines +52 to +58
`${e.timestamp}
Type: Query
Params: ${e.params}
Query: ${e.query}
Duration: ${e.duration}
Target: ${e.target}
`,
Comment thread src/prisma/client.ts
level: 'warn',
message:
`${e.timestamp}
Type: Info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat/logger

2 participants