Skip to content

feat: add Winston logging and Sarvam fallback provider - #56

Merged
kaihere14 merged 1 commit into
mainfrom
feat/structured-logging-and-sarvam-fallback
Sep 8, 2026
Merged

feat: add Winston logging and Sarvam fallback provider#56
kaihere14 merged 1 commit into
mainfrom
feat/structured-logging-and-sarvam-fallback

Conversation

@kaihere14

@kaihere14 kaihere14 commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Replace all 115 console.* calls with a tagged Winston logger and
finish
wiring Sarvam as the fallback provider across every LLM path.

Logging (src/utils/logger.js):

  • One base logger with tagged children: server, github, ai, worker, queue, db, auth, email, convex, redis. The tag identifies the subsystem, so call sites no longer hand-write "[LLM]"-style prefixes into their messages.
  • AI lines carry the provider as a field (ai:Gemini, ai:Sarvam), so a fallback run reads as one provider failing and the other succeeding.
  • Structured meta instead of interpolated prose: repo, commit, path, provider, durationMs, status.
  • Readable lines in development, JSON in production, level via LOG_LEVEL.
  • Log uncaught exceptions and unhandled rejections.
  • Add per-request logging middleware (method, url, status, duration).
  • Drop the full completion dump in ai.sdk.js to debug level; it was printing every generated README to stdout.

Sarvam fallback:

  • Route every Sarvam call through one method that checks for the API key, logs duration and failures, and rejects empty responses.
  • Add cleanup() to SarvamProvider and fall back in LlmService.cleanup().
  • Pass a fallback provider into the patch pipeline, which previously had none and failed the run outright when Gemini was exhausted.
  • Log the reason on every fallback; the catch blocks were swallowing it.

Live updates:

  • Rewrite the Convex live-update copy shown in the frontend: no vendor names, no internal mode jargon, present-tense steps.
  • Fire the patch pipeline's "rewriting sections" update before the model call rather than after it.

Summary by CodeRabbit

  • New Features

    • Added structured, contextual logging across server operations, including requests, authentication, database connections, email, GitHub, AI providers, queues, and background jobs.
    • Added request logging with response status and duration details.
    • Added environment-aware log formatting, levels, and exception handling.
  • Bug Fixes

    • Improved visibility into errors and warnings without changing request handling or application behavior.

  Replace all 115 console.* calls with a tagged Winston logger and
  finish
  wiring Sarvam as the fallback provider across every LLM path.

  Logging (src/utils/logger.js):
  - One base logger with tagged children: server, github, ai, worker,
    queue,
    db, auth, email, convex, redis. The tag identifies the subsystem, so
    call
    sites no longer hand-write "[LLM]"-style prefixes into their
    messages.
  - AI lines carry the provider as a field (ai:Gemini, ai:Sarvam), so a
    fallback run reads as one provider failing and the other succeeding.
  - Structured meta instead of interpolated prose: repo, commit, path,
    provider, durationMs, status.
  - Readable lines in development, JSON in production, level via
    LOG_LEVEL.
  - Log uncaught exceptions and unhandled rejections.
  - Add per-request logging middleware (method, url, status, duration).
  - Drop the full completion dump in ai.sdk.js to debug level; it was
    printing every generated README to stdout.

  Sarvam fallback:
  - Route every Sarvam call through one method that checks for the API
    key,
    logs duration and failures, and rejects empty responses.
  - Add cleanup() to SarvamProvider and fall back in
    LlmService.cleanup().
  - Pass a fallback provider into the patch pipeline, which previously
    had
    none and failed the run outright when Gemini was exhausted.
  - Log the reason on every fallback; the catch blocks were swallowing
    it.

  Live updates:
  - Rewrite the Convex live-update copy shown in the frontend: no vendor
    names, no internal mode jargon, present-tense steps.
  - Fire the patch pipeline's "rewriting sections" update before the
    model
    call rather than after it.
@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
daemon-doc Ready Ready Preview Sep 8, 2026 9:56am UTC
1 Skipped Deployment
Project Deployment Actions Updated
read-it Skipped Skipped Sep 8, 2026 9:56am UTC

@kaihere14
kaihere14 merged commit b6a2a64 into main Sep 8, 2026
3 of 8 checks passed
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 9a246a8e-4cbd-452b-affc-12a7d8d23009

📥 Commits

Reviewing files that changed from the base of the PR and between 2d4ee50 and c2e70ac.

⛔ Files ignored due to path filters (1)
  • server/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (18)
  • server/package.json
  • server/src/controllers/email.controller.js
  • server/src/controllers/github.controller.js
  • server/src/controllers/oauthcontroller.js
  • server/src/db/connectDB.js
  • server/src/index.js
  • server/src/llm/ai.sdk.js
  • server/src/llm/llm.service.js
  • server/src/llm/providers/gemini.provider.js
  • server/src/llm/providers/sarvam.provider.js
  • server/src/llm/readme.generate.js
  • server/src/llm/readme.patch.js
  • server/src/middlewares/auth.middleware.js
  • server/src/services/convex.service.js
  • server/src/services/email.queue.js
  • server/src/services/github.service.js
  • server/src/utils/git.worker.js
  • server/src/utils/logger.js

📝 Walkthrough

Walkthrough

The server adds Winston-based structured logging with tagged subsystem and provider loggers. It replaces console output across HTTP requests, integrations, AI workflows, repository workers, startup, error handling, and background processing.

Changes

Structured logging rollout

Layer / File(s) Summary
Logger foundation and request middleware
server/package.json, server/src/utils/logger.js
Adds Winston, tagged loggers, metadata formatting, environment-specific output, exception handling, and completed-request logging middleware.
Application and integration logging
server/src/index.js, server/src/db/connectDB.js, server/src/middlewares/auth.middleware.js, server/src/controllers/oauthcontroller.js, server/src/controllers/email.controller.js, server/src/services/email.queue.js, server/src/services/convex.service.js
Replaces console output with structured logs for startup, database, authentication, OAuth, email, queue, and Convex operations.
GitHub controller and service logging
server/src/controllers/github.controller.js, server/src/services/github.service.js
Adds contextual logs for repository access, webhooks, analytics, cleanup, file operations, and commits.
AI pipeline logging
server/src/llm/ai.sdk.js, server/src/llm/llm.service.js, server/src/llm/providers/*, server/src/llm/readme.generate.js, server/src/llm/readme.patch.js
Adds provider-aware logs for generation modes, fallbacks, context analysis, README generation, patching, and completion metrics.
Repository worker logging
server/src/utils/git.worker.js
Adds structured logs for Redis lifecycle events, repository scans, README updates, commits, cleanup, and failures.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Express
  participant requestLogger
  participant RouteHandler
  participant serverLog
  Client->>Express: send HTTP request
  Express->>requestLogger: enter middleware
  requestLogger->>RouteHandler: call next()
  RouteHandler->>serverLog: log application event
  RouteHandler-->>Express: return response
  Express-->>requestLogger: complete response
  requestLogger->>serverLog: log status and duration
Loading
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/structured-logging-and-sarvam-fallback

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kaihere14
kaihere14 deleted the feat/structured-logging-and-sarvam-fallback branch September 8, 2026 09:59
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.

1 participant