Skip to content

feat: Configure dynamic loglevel update#157

Merged
nssherpa merged 2 commits intomainfrom
nsherpa/debug-logging
Feb 24, 2026
Merged

feat: Configure dynamic loglevel update#157
nssherpa merged 2 commits intomainfrom
nsherpa/debug-logging

Conversation

@nssherpa
Copy link
Collaborator

@nssherpa nssherpa commented Feb 24, 2026

Testing

Tested with switching from info to debug to info..

curl -X PUT "http://localhost:8080/admin/log/level?level=debug"
DEBUG
curl http://localhost:8080/admin/log/level
DEBUG
curl -X PUT "http://localhost:8080/admin/log/level?level=info"
INFO
Screenshot 2026-02-24 at 1 22 02 PM

@nssherpa nssherpa changed the title feat: Make changing log level dynamic feat: Configure dynamic logs Feb 24, 2026
@nssherpa nssherpa marked this pull request as ready for review February 24, 2026 21:20
@nssherpa nssherpa requested a review from a team as a code owner February 24, 2026 21:20
@nssherpa nssherpa requested review from js-murph and removed request for a team February 24, 2026 21:20
func Configure(ctx context.Context, config Config) (*slog.Logger, context.Context) {
// Configure sets up logging with the given config and returns a logger, a LevelVar
// that can be used to dynamically change the log level at runtime, and the updated context.
func Configure(ctx context.Context, config Config) (*slog.Logger, *slog.LevelVar, context.Context) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that there's only one LevelVar for the entire process, I think it's safe to just make this a global and have corresponding global SetLevel()/GetLevel() functions. That will vastly simplify this PR.

@nssherpa nssherpa changed the title feat: Configure dynamic logs feat: Configure dynamic loglevel update Feb 24, 2026
@alecthomas
Copy link
Collaborator

I'd also maybe consider using JSON payload for getting/setting the level for consistency with the rest of the system, but I'm not that fussed for an admin endpoint.

@nssherpa
Copy link
Collaborator Author

Skipping the json payload for the endpoint for now. But addressed the other comment.

@nssherpa nssherpa merged commit 863d935 into main Feb 24, 2026
6 checks passed
@nssherpa nssherpa deleted the nsherpa/debug-logging branch February 24, 2026 23:31
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