Skip to content

docs: update logging docs for slog-native architecture#73

Merged
ankurs merged 7 commits intomainfrom
docs/slog-native-logging
Apr 12, 2026
Merged

docs: update logging docs for slog-native architecture#73
ankurs merged 7 commits intomainfrom
docs/slog-native-logging

Conversation

@ankurs
Copy link
Copy Markdown
Member

@ankurs ankurs commented Apr 11, 2026

Summary

  • Rewrite howto/Log.md — replace BaseLogger/SetLogger/cbslog patterns with slog-native (SetDefault, NewHandler, NewHandlerWithInner, slog.LogAttrs, AddAttrsToContext)
  • Update context-aware logs examples to show both AddAttrsToContext (typed) and AddToContext (untyped)
  • Update OverrideLogLevel example to use slog.LogAttrs
  • Fix bug in howto/production.md: log.AddToLogContext()log.AddToContext()
  • Update Index.md feature table and package table
  • Update Packages.md log package description
  • Update FAQ.md: log.SetLogger()log.SetDefault()

Test plan

  • Verify Jekyll builds locally
  • Check all code examples render correctly
  • Verify links to pkg.go.dev still work

Ref: go-coldbrew/log#27

Summary by CodeRabbit

  • Documentation
    • Revised logging docs to describe a native slog-based handler that injects per-request context fields (trace ID, RPC/HTTP info) and shows composable handler usage and examples.
    • Added guidance for adding typed and untyped log fields via new context APIs and updated example log calls and JSON output.
    • Clarified which context fields are included when sending data to error trackers.
    • Corrected FAQ guidance on the init-only configuration pattern.

Update all logging references to reflect the slog-native Handler:
- howto/Log.md: rewrite backends section (SetDefault/NewHandler/NewHandlerWithInner),
  update context-aware logs to show AddAttrsToContext + slog.LogAttrs,
  update OverrideLogLevel example with slog
- Packages.md: rewrite log package description for slog-native
- Index.md: update feature table and package table
- FAQ.md: SetLogger -> SetDefault
- howto/production.md: fix wrong function name (AddToLogContext -> AddToContext)

Ref: go-coldbrew/log#27
Copilot AI review requested due to automatic review settings April 11, 2026 14:25
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 03473d6b-af0a-4a3f-a9c0-85064743f9d3

📥 Commits

Reviewing files that changed from the base of the PR and between 9e3cb09 and 78a9069.

📒 Files selected for processing (2)
  • Index.md
  • howto/Log.md
✅ Files skipped from review due to trivial changes (1)
  • howto/Log.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • Index.md

📝 Walkthrough

Walkthrough

Updated documentation across multiple markdown files to reflect a migration to a slog-native logging model using a custom slog.Handler, replaced log.SetLogger() references with log.SetDefault(), and documented new context APIs (log.AddAttrsToContext, log.AddToContext) plus handler composability. All edits are documentation-only.

Changes

Cohort / File(s) Summary
Core docs & index
FAQ.md, Index.md, Packages.md
Replaced references to pluggable logging/backends and log.SetLogger() with slog-native descriptions, log.SetDefault(), handler-based design, and new context APIs; updated feature/package descriptions to emphasize a custom slog.Handler that injects per-request fields.
How-to & production guidance
howto/Log.md, howto/production.md
Rewrote logging how-to to show handler setup (log.SetDefault(log.NewHandler(...))), added log.NewHandlerWithInner composition examples, switched examples to slog.LogAttrs, documented log.AddAttrsToContext/log.AddToContext, and clarified which context fields are included for error trackers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I hopped from backends old to new,
A slog-handler kissed by dew.
Context fields line up in queue,
Trace IDs and paths peek through,
Logs snug, I nibble a carrot chew. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'docs: update logging docs for slog-native architecture' directly and accurately describes the main change: comprehensive documentation updates reflecting a shift to slog-native logging architecture across multiple doc files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/slog-native-logging

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@howto/Log.md`:
- Around line 54-61: The example init function uses os.Stdout but the import
block is missing the "os" package; update the import list to include "os" so the
snippet compiles. Specifically, in the example containing func init() and
variables inner, call to slog.NewJSONHandler(os.Stdout, nil), and
log.SetDefault(log.NewHandlerWithInner(inner)), add "os" to the import block
alongside "log/slog" and "github.com/go-coldbrew/log".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 00c07321-05df-4ad9-bdf4-e1ca35ef6a03

📥 Commits

Reviewing files that changed from the base of the PR and between e0e8aa6 and aafefef.

📒 Files selected for processing (5)
  • FAQ.md
  • Index.md
  • Packages.md
  • howto/Log.md
  • howto/production.md

Comment thread howto/Log.md
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates ColdBrew documentation to reflect the newer slog-native logging architecture and APIs, replacing older logger configuration patterns and correcting outdated references.

Changes:

  • Rewrites logging guidance to emphasize native slog usage (slog.LogAttrs) and the framework-provided composable slog.Handler.
  • Updates docs/examples to use log.SetDefault, log.AddAttrsToContext, and log.AddToContext, including a production doc fix.
  • Refreshes package/feature descriptions to describe slog-native logging behavior and context field injection.

Reviewed changes

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

Show a summary per file
File Description
Packages.md Updates the log package description to reflect slog-native handler-based logging and context field injection.
Index.md Updates the “Structured Logging” feature and the log module description to describe slog-native logging.
howto/production.md Fixes/updates logging context API references in production data handling documentation.
howto/Log.md Rewrites the logging how-to to use slog-native APIs and updated ColdBrew logging helpers.
FAQ.md Updates init-only configuration examples to reference log.SetDefault() instead of log.SetLogger().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread howto/Log.md Outdated
Comment thread howto/Log.md
Comment thread howto/Log.md
Comment thread howto/Log.md
Comment thread Index.md Outdated
ankurs added 2 commits April 11, 2026 22:32
Add concrete examples showing how to compose ColdBrew's Handler with
custom inner handlers, slog-multi fan-out, and external middleware wrapping.
All done through the log package via NewHandlerWithInner.
Add context, net/http, os imports to code examples so they compile
when copy-pasted. Addresses Copilot review comments.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread howto/Log.md Outdated
Comment thread howto/Log.md
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread howto/Log.md
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread howto/Log.md Outdated
Comment thread howto/Log.md
@ankurs ankurs merged commit 286fb75 into main Apr 12, 2026
7 checks passed
@ankurs ankurs deleted the docs/slog-native-logging branch April 12, 2026 03:58
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.

2 participants