Skip to content

fix: route all slog output through component logger - #91

Merged
pavelanni merged 1 commit into
mainfrom
fix/consistent-log-format
Jun 4, 2026
Merged

pavelanni merged 1 commit into
mainfrom
fix/consistent-log-format

Conversation

@pavelanni

@pavelanni pavelanni commented Jun 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Set slog.SetDefault after creating the component logger so direct slog.Info() calls use the same format

Fixes inconsistent log output in K8s: startup logs used JSON (via component logger) but tool loop logs used Go's default text format (via direct slog.Info() calls).

Before (K8s):

{"time":"...","level":"INFO","msg":"LLM provider initialized","component":"DOCSCLAW",...}
2026/06/04 01:12:45 INFO LLM response received provider=openai ...

After (K8s):

{"time":"...","level":"INFO","msg":"LLM provider initialized","component":"DOCSCLAW",...}
{"time":"...","level":"INFO","msg":"LLM response received","component":"DOCSCLAW",...}

Test plan

  • go build and go test ./internal/cmd/ pass

Summary by CodeRabbit

  • Chores
    • Updated logging configuration to ensure consistent logger usage throughout the process by aligning the default logger with the service's configured logging setup.

Set slog.SetDefault after creating the component logger so that
direct slog.Info() calls in pkg/tools/loop.go and other packages
use the same handler (JSON in K8s, color text in terminals) instead
of Go's default text format.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 2a4ea0f3-13b8-4774-b96f-d45e7ee624e5

📥 Commits

Reviewing files that changed from the base of the PR and between bdd8048 and 75bfc19.

📒 Files selected for processing (1)
  • internal/cmd/serve.go

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting


📝 Walkthrough

Walkthrough

The serve command now integrates Go's standard log/slog package by importing it and registering the application's component logger as the default slog logger. This ensures any slog calls throughout the process use the configured agent logging infrastructure.

Changes

Slog Default Logger Configuration

Layer / File(s) Summary
Slog default logger setup
internal/cmd/serve.go
log/slog is imported and the component logger created for the agent is registered as the default slog logger via slog.SetDefault(), aligning all slog usage in the process with the application's logging configuration.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/consistent-log-format

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

@pavelanni
pavelanni merged commit 6b6b80e into main Jun 4, 2026
3 checks passed
@pavelanni
pavelanni deleted the fix/consistent-log-format branch June 4, 2026 01:19
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