Skip to content

Entry.Level compared against DebugLevel is always false, so gated debug diagnostics never fire #4438

Description

@stevenvegt

The module log.Logger() helpers return a *logrus.Entry created with logrus.StandardLogger().WithField(...). Entry.Level is the per-message level, which logrus only sets on the entry copy used during an actual log call; on these long-lived entries it stays at the zero value, PanicLevel (0). A comparison like log.Logger().Level >= logrus.DebugLevel is therefore always 0 >= 5, i.e. false, regardless of the configured verbosity.

Three call sites gate debug diagnostics this way, so those diagnostics can never be enabled:

  • auth/services/irma/signer.go:121: the QR code for an IRMA session is never printed.
  • vcr/search.go:104: the debug summary of credentials filtered out of search results (error message counts) is never logged.
  • storage/engine.go:428: goose.SetVerbose() always receives false, so migration verbosity cannot be switched on.

None of these discloses anything; they are missing diagnostics only. The fix is to repair the check, for example with logrus.IsLevelEnabled(logrus.DebugLevel) as already used correctly at vcr/api/vcr/v2/registry.go:68 (valid because the module loggers wrap the standard logger), or log.Logger().Logger.IsLevelEnabled(...).

A fourth instance in the HTTP request logger gated request header capture, including the Authorization header. That one was removed rather than repaired in #4437, because enabling it would have written bearer tokens to the logs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions