Skip to content

fix(logger): honor LOG_LEVEL - #100

Open
lbarrosby wants to merge 1 commit into
kagent-dev:mainfrom
lbarrosby:fix/log-level-env
Open

lbarrosby wants to merge 1 commit into
kagent-dev:mainfrom
lbarrosby:fix/log-level-env

Conversation

@lbarrosby

Copy link
Copy Markdown

Closes #94.

DEVELOPMENT.md documents LOG_LEVEL (and suggests LOG_LEVEL=debug go run ./cmd), and the e2e helpers set LOG_LEVEL=debug, but logger.Init always built the handler with slog.LevelInfo, so the variable had no effect and the existing Debug calls never printed.

Init now reads LOG_LEVEL and parses it with slog.Level.UnmarshalText, so debug, info, warn and error work case-insensitively (as do slog offsets such as info+2). Unset or invalid values keep today's default of info. The docs line now says so.

I left the Helm chart alone: tools.loglevel in values.yaml is still not rendered into the Deployment, and wiring it with its current default (debug) would change the default verbosity of every install. That fits better with #92.

Test: TestInitHonorsLogLevel in internal/logger/logger_test.go checks which levels are enabled for unset, debug, DEBUG, info, warn, error and an invalid value. On main the debug, DEBUG, warn and error cases fail; with this change all pass. go test -tags=test ./internal/... ./cmd/..., go vet and golangci-lint run --build-tags=test pass locally.

AI disclosure: written with the help of Claude Code, reviewed and tested by me.

DEVELOPMENT.md documents LOG_LEVEL, but the logger was always created at
info level, so LOG_LEVEL=debug had no effect. Parse it with
slog.Level.UnmarshalText and fall back to info when it is unset or
invalid.

Closes kagent-dev#94

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
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.

LOG_LEVEL is documented but not implemented

1 participant