Skip to content

feat(logger): Add SetOutput and GetOutput for dynamic log redirection#310

Merged
moshloop merged 1 commit intomasterfrom
pr/atomic-logger
Apr 24, 2026
Merged

feat(logger): Add SetOutput and GetOutput for dynamic log redirection#310
moshloop merged 1 commit intomasterfrom
pr/atomic-logger

Conversation

@moshloop
Copy link
Copy Markdown
Member

Implement atomic-backed output redirection for all loggers (root and named) without requiring handler reconstruction. Uses sync/atomic.Value to wrap io.Writer in outputBox, and a sharedOutput indirection writer that all handlers capture. This allows SetOutput to retarget existing loggers immediately and safely for concurrent callers.

Adds comprehensive test coverage including new logger redirection, existing logger retargeting, restore semantics, nil handling, and concurrent safety.

Also adds .gavel.yaml configuration to ignore false-positive secret detections in test fixtures and certificates.

Implement atomic-backed output redirection for all loggers (root and named) without requiring handler reconstruction. Uses sync/atomic.Value to wrap io.Writer in outputBox, and a sharedOutput indirection writer that all handlers capture. This allows SetOutput to retarget existing loggers immediately and safely for concurrent callers.

Adds comprehensive test coverage including new logger redirection, existing logger retargeting, restore semantics, nil handling, and concurrent safety.

Also adds .gavel.yaml configuration to ignore false-positive secret detections in test fixtures and certificates.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

Warning

Rate limit exceeded

@moshloop has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 21 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 21 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c3617a32-18f0-41fc-8042-a1451f99d304

📥 Commits

Reviewing files that changed from the base of the PR and between 412d718 and cfcaef8.

📒 Files selected for processing (3)
  • .gavel.yaml
  • logger/slog.go
  • logger/slog_setoutput_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pr/atomic-logger
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch pr/atomic-logger

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 and usage tips.

@moshloop moshloop enabled auto-merge (rebase) April 24, 2026 11:40
@github-actions
Copy link
Copy Markdown

Gavel summary

Source Pass Fail Skip Duration
collections 49 0 0 3.1s
files 41 0 0 116ms
github.com/flanksource/commons/certs 4 0 0 500ms
github.com/flanksource/commons/cmd/hx 8 0 0 -
github.com/flanksource/commons/cmd/hx/parse 26 0 0 -
github.com/flanksource/commons/collections/syncmap 10 0 0 -
github.com/flanksource/commons/context 1 0 0 -
github.com/flanksource/commons/duration 2 0 0 -
github.com/flanksource/commons/files 16 0 0 -
github.com/flanksource/commons/har 23 0 0 -
github.com/flanksource/commons/hash 13 0 0 -
github.com/flanksource/commons/http 57 0 2 2.4s
github.com/flanksource/commons/logger 33 0 0 30ms
github.com/flanksource/commons/logger/httpretty/internal/color 15 0 0 -
github.com/flanksource/commons/logger/httpretty/internal/header 1 0 0 -
github.com/flanksource/commons/lookup 7 0 0 20ms
github.com/flanksource/commons/test 5 0 1 30ms
github.com/flanksource/commons/text 1 0 0 -
github.com/flanksource/commons/tokenizer 3 0 0 -
lint: betterleaks 0 0 1 -
lint: eslint 0 0 1 -
lint: golangci-lint 0 0 1 -
lint: jscpd 0 0 1 -
lint: markdownlint 0 0 1 -
lint: pyright 0 0 1 -
lint: ruff 0 0 1 -
lint: vale 0 0 1 -
logger 41 0 0 848.231µs
set 7 0 0 398.031µs

Totals: 363 passed · 0 failed · 11 skipped · 6.2s

View full results

@moshloop moshloop merged commit 441e674 into master Apr 24, 2026
5 of 6 checks passed
@moshloop moshloop deleted the pr/atomic-logger branch April 24, 2026 11:43
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.51.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant