From caf98b4dfe5db2eda7fa4ce12a12cc3ba56e8879 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Fri, 7 Feb 2025 15:30:03 +0700 Subject: [PATCH] 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. --- cmd/cli/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 819797a..73a601d 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -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) }