Fix LOG_LEVEL=debug never actually producing debug output - #6
Open
framinosona wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Small companion fix found while investigating glanceapp/glance#1068 (empty mountpoints — real fix is [glanceapp/glance#1069]... actually see the linked
pkg/sysinfoPR for that one).The bug
logDebug(computed fromLOG_LEVEL=debugor the dev-build default) correctly gates whetherserver.gocallsslog.Debug(...)whensysinfo.Collectreturns errors — but nothing anywhere in the codebase ever configureslog/slog's default handler to actually emit Debug-level records.log/slog's package default handler floors atInfo, so everyslog.Debug()call was being silently discarded regardless ofLOG_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 whenlogDebugis true, so the existinglogDebug-gatedslog.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 inpkg/sysinfo(separate PR againstglanceapp/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.