Skip to content

Fix LOG_LEVEL=debug never actually producing debug output - #6

Open
framinosona wants to merge 1 commit into
glanceapp:mainfrom
framinosona:fix/debug-logging
Open

Fix LOG_LEVEL=debug never actually producing debug output#6
framinosona wants to merge 1 commit into
glanceapp:mainfrom
framinosona:fix/debug-logging

Conversation

@framinosona

Copy link
Copy Markdown

Small companion fix found while investigating glanceapp/glance#1068 (empty mountpoints — real fix is [glanceapp/glance#1069]... actually see the linked pkg/sysinfo PR for that one).

The bug

logDebug (computed from LOG_LEVEL=debug or the dev-build default) correctly gates whether server.go calls slog.Debug(...) when sysinfo.Collect returns errors — but nothing anywhere in the codebase ever configures log/slog's default handler to actually emit Debug-level records. log/slog's package default handler floors at Info, so every slog.Debug() call was being silently discarded regardless of LOG_LEVEL, every time, unconditionally.

Confirmed by grepping the whole repo for SetDefault/SetLogLoggerLevel/HandlerOptions — nothing sets a Debug-level handler anywhere.

The fix

One line: slog.SetLogLoggerLevel(slog.LevelDebug) at startup when logDebug is true, so the existing logDebug-gated slog.Debug() calls actually reach output.

Why this matters beyond just "logs work now"

This was the actual blocker to diagnosing the disk-mountpoints-empty issue properly — without working debug output, there was no way to see why sysinfo.Collect's auto-detection was coming back empty (silently, no error surfaced anywhere). Fixing this first is what let me find the real root cause in pkg/sysinfo (separate PR against glanceapp/glance, linked above) with actual evidence instead of guessing.

Tested: built from source, ran with LOG_LEVEL=debug, confirmed debug-level log lines now actually appear in container logs where they previously never did under any configuration.

logDebug correctly gates whether slog.Debug() gets called (server.go),
but nothing anywhere configures slog's default handler to actually
emit Debug-level records -- log/slog's package default floors at Info,
so every slog.Debug() call was silently discarded regardless of
LOG_LEVEL. This made the existing debug logging around sysinfo
collection errors permanently unreachable, which is exactly the output
needed to diagnose why mountpoints sometimes come back empty (see
glanceapp/glance#1068 and the accompanying pkg/sysinfo fix).

Fix: call slog.SetLogLoggerLevel(slog.LevelDebug) at startup when
logDebug is true, so the existing logDebug-gated slog.Debug() calls
actually reach output.
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.

1 participant