Skip to content

🧹 Centralize backend logging using a wrapper utility - #8

Closed
davidraehles wants to merge 3 commits into
mainfrom
code-health-logger-wrapper-4467161664679516936
Closed

🧹 Centralize backend logging using a wrapper utility#8
davidraehles wants to merge 3 commits into
mainfrom
code-health-logger-wrapper-4467161664679516936

Conversation

@davidraehles

Copy link
Copy Markdown
Collaborator

This PR improves the code health of the backend by standardizing logging. Instead of using console.log and console.error directly throughout the codebase, we now use a centralized logger utility.

🎯 What:

  • Added a wrapper around console methods in backend/src/utils/logger.ts.
  • Replaced all direct console calls in auth.ts, notes.ts, and server.ts with calls to the new logger utility.
  • Renamed error variable in catch blocks to err where modifications were made to improve clarity and consistency.

💡 Why:

  • Centralizing logging allows for a single point of control.
  • It makes it easier to change logging behavior globally (e.g., adding timestamps, formatting, or sending logs to an external service) without touching every file.
  • It follows the project's recommended logging standard.

Verification:

  • Verified the logger utility works correctly using a standalone script executed with bun.
  • Confirmed that all direct console calls (except within the logger itself) have been replaced using grep.
  • Ran pnpm install and attempted pnpm run build to ensure no syntax errors were introduced.

Result:

  • Improved maintainability and standard-compliant logging across the backend.

PR created automatically by Jules for task 4467161664679516936 started by @davidraehles

Introduced a centralized logger utility in `backend/src/utils/logger.ts` and updated all instances of `console.log` and `console.error` in the backend to use this utility. This improves maintainability and allows for easier future upgrades to a full logging library.
Changes:
- Created `backend/src/utils/logger.ts`
- Updated `backend/src/routes/auth.ts`
- Updated `backend/src/routes/notes.ts`
- Updated `backend/src/server.ts`
- Added `backend/pnpm-lock.yaml` (automatically generated during verification)
Co-authored-by: davidraehles <6085055+davidraehles@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

CopilotAI review requested due to automatic review settings February 18, 2026 19:30

CopilotAI left a comment

Copy link
Copy Markdown

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 centralizes backend logging by introducing a small logger utility and updating backend entrypoints/routes to use it instead of direct console.* calls.

Changes:

  • Added backend/src/utils/logger.ts as a wrapper around console methods.
  • Replaced direct console.log/error usage in server.ts, routes/auth.ts, and routes/notes.ts with the new logger.
  • Added backend/pnpm-lock.yaml (new lockfile).

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
backend/src/utils/logger.tsIntroduces centralized logger wrapper functions.
backend/src/server.tsSwitches startup log to logger.info.
backend/src/routes/notes.tsReplaces route error logging with logger.error and renames caught error to err.
backend/src/routes/auth.tsReplaces route error logging with logger.error and renames caught error to err.
backend/pnpm-lock.yamlAdds a pnpm lockfile for backend dependencies.
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.

Comment threadbackend/src/utils/logger.ts Outdated
Comment on lines +5 to +17
export const info = (...args: any[]) => {
console.log(...args);
};

export const error = (...args: any[]) => {
console.error(...args);
};

export const warn = (...args: any[]) => {
console.warn(...args);
};

export const debug = (...args: any[]) => {

CopilotAIFeb 18, 2026

Copy link

Choose a reason for hiding this comment

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

logger uses any[] for arguments, which defeats strict typing and makes it easy to accidentally log values with unsafe assumptions. Prefer typing the rest parameters as unknown[] or (even better) Parameters<typeof console.log> / Parameters<typeof console.error> so call sites stay type-safe while still matching console behavior.

Suggested change
exportconstinfo=(...args: any[])=>{
console.log(...args);
};
exportconsterror=(...args: any[])=>{
console.error(...args);
};
exportconstwarn=(...args: any[])=>{
console.warn(...args);
};
exportconstdebug=(...args: any[])=>{
exportconstinfo=(...args: Parameters<typeofconsole.log>)=>{
console.log(...args);
};
exportconsterror=(...args: Parameters<typeofconsole.error>)=>{
console.error(...args);
};
exportconstwarn=(...args: Parameters<typeofconsole.warn>)=>{
console.warn(...args);
};
exportconstdebug=(...args: Parameters<typeofconsole.debug>)=>{

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Changed all logger function rest parameters from any[] to unknown[]. TypeScript compiles clean.

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.

I've updated backend/src/utils/logger.ts to use unknown[] for better type safety as requested. Thank you!

Comment threadbackend/pnpm-lock.yaml Outdated
Comment on lines +1 to +5
lockfileVersion: '9.0'

settings:
autoInstallPeers: true
excludeLinksFromLockfile: false

CopilotAIFeb 18, 2026

Copy link

Choose a reason for hiding this comment

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

This adds a pnpm-lock.yaml while the backend already has package-lock.json. Having multiple lockfiles for the same package.json can cause inconsistent dependency resolution across environments/CI. Either remove pnpm-lock.yaml (if the project standard is npm) or migrate fully to pnpm and delete package-lock.json + update tooling/docs accordingly.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Removed pnpm-lock.yaml. This repo uses npm with package-lock.json.

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.

Apologies for the oversight. I've removed backend/pnpm-lock.yaml and ensured that package-lock.json is used instead, following the repository standards.

Davidand others added 2 commits February 18, 2026 21:18
- Updated `backend/src/utils/logger.ts` to use `unknown[]` instead of `any[]` for better type safety.
- Removed `backend/pnpm-lock.yaml` as the repository standard is `npm` with `package-lock.json`.
- Updated `backend/package-lock.json` via `npm install`.
Co-authored-by: davidraehles <6085055+davidraehles@users.noreply.github.com>
Sign up for freeto 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.

2 participants

@davidraehles