Skip to content

fix: load log configuration from config file#667

Open
jeengbe wants to merge 1 commit into
spiffe:mainfrom
jeengbe:je-log-from-config
Open

fix: load log configuration from config file#667
jeengbe wants to merge 1 commit into
spiffe:mainfrom
jeengbe:je-log-from-config

Conversation

@jeengbe
Copy link
Copy Markdown

@jeengbe jeengbe commented Apr 30, 2026

I'm relatively new to Go, so please bear with me :)

The default logf.Log returns a delegatingLogSink whose implementation can (crucially) only be overwritten once. So the first time the logger is configured with _ = setLogger(&opts, "", ""), that call only includes CLI flags, but not options loaded from the configuration file.

Instead, this PR hard-wires the setupLog logger to use zap.New(zap.UseDevMode(true)), which ensures that all setup/teardown logs remain visible while allowing the later real setLogger to replace the remaining application loggers from ctrl.Log.

This has two side effects:

  • The setup logger no longer respects CLI flags for log level/format
  • Potential callers that don't bind to setupLog explicitly don't print logs before setLogger is called

I don't see a clean way around that second catch-22. Given that the global delegating logger instance may only be rebound once and loading the configuration file itself may possibly emit logs (I did not find that it does, but it seems not to be prohibited_ from doing so), the only clean fix I see is to not use the global logger from the pre-configuration pass?

Signed-off-by: Jesper Engberg <jeengbe@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.

1 participant