Skip to content

Update Slogs logger to handle AddSource#87

Merged
Starttoaster merged 15 commits intomainfrom
newlogger
Jan 28, 2026
Merged

Update Slogs logger to handle AddSource#87
Starttoaster merged 15 commits intomainfrom
newlogger

Conversation

@Starttoaster
Copy link
Copy Markdown
Contributor

@Starttoaster Starttoaster commented Jan 27, 2026

AddSource, when enabled on a slog logger, adds context to a log about the location in the code of the caller. This can help with debugging in circumstances where multiple pieces of code may have similar message data. See an example below:

time=2026-01-26T16:27:54.487-08:00 level=ERROR source=/path/in/program/main.go:25 msg="loading config" error="CLOUDFLARE_API_TOKEN environment variable is required"

Note

Medium Risk
Changes the logging API (Init signature) and rewires log emission, which may break existing callers and subtly affect log formatting/source attribution if the new record construction is incorrect.

Overview
Updates pkg/slogs to support configurable handler behavior via options: Init now accepts functional options (e.g., WithSourceContext to emit correct caller locations and WithWriter to redirect output) and the logger is reworked to build slog.Records manually so AddSource points at the real caller.

Adds level-specific and context-aware logging methods (Debug/Info/Warn/Error/Fatal plus *Context variants) with internal error handling, and updates the README with the new initialization options and examples.

Written by Cursor Bugbot for commit c20bfca. This will update automatically on new commits. Configure here.

cmmarslender
cmmarslender previously approved these changes Jan 28, 2026
@cmmarslender cmmarslender marked this pull request as ready for review January 28, 2026 03:53
Comment thread pkg/slogs/slogs.go Outdated
Comment thread pkg/slogs/slogs.go Outdated
Comment thread pkg/slogs/slogs.go Outdated
Comment thread pkg/slogs/slogs.go
Comment thread pkg/slogs/slogs.go
Comment thread pkg/slogs/slogs.go Outdated
Comment thread pkg/slogs/slogs.go
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment thread pkg/slogs/slogs.go
@Starttoaster Starttoaster merged commit d33c296 into main Jan 28, 2026
11 checks passed
@Starttoaster Starttoaster deleted the newlogger branch January 28, 2026 22:32
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