Skip to content

Log level config silently overridden by env var check (config_loader.go) #3211

Description

@hklcf

Bug Description

In config_loader.go, the log level set by the user in the configuration file is overridden by an environment variable check. If a user explicitly sets log_level = 0 (debug) in the config file but does not set the DEBUG environment variable, the log level gets silently overridden to info.

Affected Code

config_loader.go:32-34:

if dlog.LogLevel() <= dlog.SeverityDebug && os.Getenv("DEBUG") == "" {
    dlog.SetLogLevel(dlog.SeverityInfo)
}

Impact

User-configured debug logging is silently ignored. Users who set log_level = 0 in their config file expecting debug output will not see it unless they also set the DEBUG environment variable. This is surprising behavior and contradicts the explicit configuration file setting.

Fix

Either remove this override entirely (letting the config file control log level) or document it clearly and only apply it when the user hasn't explicitly configured the log level:

// Only override if the user hasn't explicitly set a log level in the config
if os.Getenv("DEBUG") == "" && defaultLogLevelUsed {
    // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions