cmd/cli: ignore log file config for interactive logging

Otherwise, the interactive commands may clobber the existed log file of
ctrld daemon, causing it stops writing log until restarted.
This commit is contained in:
Cuong Manh Le
2025-02-07 15:30:03 +07:00
committed by Cuong Manh Le
parent 398f71fd00
commit caf98b4dfe

View File

@@ -108,8 +108,14 @@ func initLogging() []io.Writer {
// initInteractiveLogging is like initLogging, but the ProxyLogger is discarded
// to be used for all interactive commands.
//
// Current log file config will also be ignored.
func initInteractiveLogging() {
initLogging()
old := cfg.Service.LogPath
cfg.Service.LogPath = ""
zerolog.TimeFieldFormat = time.RFC3339 + ".000"
initLoggingWithBackup(false)
cfg.Service.LogPath = old
l := zerolog.New(io.Discard)
ctrld.ProxyLogger.Store(&l)
}