commands: fix debug flag in standalone mode

The -D/--debug flag was not enabling debug logging in standalone mode.

Root cause: debug.Enable() was called before dockerCli.Initialize(),
but Initialize() calls SetLogLevel("") which resets logrus level to
Info, and since options.Debug was false, it wasn't re-enabled.

Fix: Pass opt.debug to options.Debug before Initialize() so it
properly enables debug level after SetLogLevel().

Signed-off-by: Sergei Khomenkov <sergey@homenkow.ru>
This commit is contained in:
Sergei Khomenkov
2025-12-07 13:52:15 +02:00
parent 22e7bf6455
commit cecd8e9570
+1
View File
@@ -57,6 +57,7 @@ func NewRootCmd(name string, isPlugin bool, dockerCli *command.DockerCli) *cobra
options := cliflags.NewClientOptions()
options.InstallFlags(nflags)
options.SetDefaultOptions(nflags)
options.Debug = opt.debug || debug.IsEnabled()
return dockerCli.Initialize(options)
}
return plugin.PersistentPreRunE(cmd, args)