Conversation
Replaced direct console.log and console.error usage with a centralized logger utility in backend/src/utils/logger.ts. This improves maintainability and provides a single point of control for logging. Co-authored-by: davidraehles <6085055+davidraehles@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR centralizes backend logging by introducing a logger utility wrapper and replacing all direct console.log and console.error calls throughout the backend codebase. The change improves maintainability by providing a single point of control for logging configuration. Additionally, the PR introduces a pnpm-lock.yaml file, suggesting a migration from npm to pnpm as the package manager.
Changes:
- Created centralized logger utility in
backend/src/utils/logger.tswith info, error, warn, and debug methods - Replaced direct console calls with logger utility imports across backend routes and server
- Added pnpm-lock.yaml lockfile to the backend directory
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| backend/src/utils/logger.ts | New centralized logger utility wrapping console methods (info, error, warn, debug) |
| backend/src/server.ts | Replaced console.log with logger.info for server startup message |
| backend/src/routes/notes.ts | Replaced all console.error calls with logger.error in error handlers |
| backend/src/routes/auth.ts | Replaced all console.error calls with logger.error in error handlers |
| backend/pnpm-lock.yaml | Added pnpm lockfile (1443 lines) indicating package manager change |
Files not reviewed (1)
- backend/pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| lockfileVersion: '9.0' | ||
|
|
||
| settings: | ||
| autoInstallPeers: true | ||
| excludeLinksFromLockfile: false | ||
|
|
There was a problem hiding this comment.
This PR introduces pnpm-lock.yaml alongside the existing package-lock.json file. Having both lockfiles can lead to inconsistencies and confusion about which package manager should be used. The repository should standardize on either npm or pnpm.
If migrating to pnpm:
- Remove package-lock.json from backend/ and frontend/
- Add .npmrc with shamefully-hoist=true or similar pnpm configuration if needed
- Document the change in the project README
- Update CI/CD pipelines to use pnpm
If staying with npm:
- Remove this pnpm-lock.yaml file
- Continue using package-lock.json
Note: The PR description mentions running "pnpm run build" which suggests pnpm is intended, but the existing package-lock.json files indicate the project was using npm previously.
There was a problem hiding this comment.
Removed pnpm-lock.yaml from the branch.
There was a problem hiding this comment.
Removed backend/pnpm-lock.yaml as requested.
| export const info = (message: string, ...args: any[]) => { | ||
| console.log(message, ...args); | ||
| }; | ||
|
|
||
| export const error = (message: string, ...args: any[]) => { | ||
| console.error(message, ...args); | ||
| }; | ||
|
|
||
| export const warn = (message: string, ...args: any[]) => { | ||
| console.warn(message, ...args); | ||
| }; | ||
|
|
||
| export const debug = (message: string, ...args: any[]) => { |
There was a problem hiding this comment.
The logger functions use any[] for the rest parameter which bypasses TypeScript's type safety. Consider using unknown[] instead to maintain type safety while still allowing flexibility. This prevents potential issues where incorrect types are passed to the logger.
Example:
export const info = (message: string, ...args: unknown[]) => {
console.log(message, ...args);
};This is a minor improvement that would make the logger more type-safe while maintaining the same functionality.
| export const info = (message: string, ...args: any[]) => { | |
| console.log(message, ...args); | |
| }; | |
| export const error = (message: string, ...args: any[]) => { | |
| console.error(message, ...args); | |
| }; | |
| export const warn = (message: string, ...args: any[]) => { | |
| console.warn(message, ...args); | |
| }; | |
| export const debug = (message: string, ...args: any[]) => { | |
| export const info = (message: string, ...args: unknown[]) => { | |
| console.log(message, ...args); | |
| }; | |
| export const error = (message: string, ...args: unknown[]) => { | |
| console.error(message, ...args); | |
| }; | |
| export const warn = (message: string, ...args: unknown[]) => { | |
| console.warn(message, ...args); | |
| }; | |
| export const debug = (message: string, ...args: unknown[]) => { |
There was a problem hiding this comment.
Changed all rest parameter types from any[] to unknown[] for stricter type safety.
There was a problem hiding this comment.
Changed rest parameter types from any[] to unknown[] for better type safety.
- Removed backend/pnpm-lock.yaml - Updated logger rest parameters to use unknown[] instead of any[] Co-authored-by: davidraehles <6085055+davidraehles@users.noreply.github.com>
🎯 What: Replaced direct
console.logandconsole.errorusage in the backend with a centralized logger utility inbackend/src/utils/logger.ts.💡 Why: This improves maintainability by providing a single point of control for logging, making it easier to swap or configure logging libraries in the future.
✅ Verification:
backend/src/utils/logger.tsand verified its content.console.calls innotes.ts,auth.ts, andserver.ts.grep.logger.tscompiles withtsc.pnpm run buildinbackend/(after generating Prisma client).✨ Result: Backend logging is now standardized and easier to manage.
PR created automatically by Jules for task 11759547853024196223 started by @davidraehles