diff --git a/cmd/cli/cli.go b/cmd/cli/cli.go index af5bb75..f59d4bb 100644 --- a/cmd/cli/cli.go +++ b/cmd/cli/cli.go @@ -267,6 +267,8 @@ func run(appCallback *AppCallback, stopCh chan struct{}) { // Log config do not have thing to validate, so it's safe to init log here, // so it's able to log information in processCDFlags. logWriters := initLogging() + // TODO: find a better way. + ctrld.ProxyLogger.Store(mainLog.Load()) // Initializing internal logging after global logging. p.initInternalLogging(logWriters) diff --git a/cmd/cli/dns_proxy.go b/cmd/cli/dns_proxy.go index 25e3e53..099bae2 100644 --- a/cmd/cli/dns_proxy.go +++ b/cmd/cli/dns_proxy.go @@ -1251,7 +1251,7 @@ func (p *prog) reinitializeOSResolver(networkChange bool) { defer func() { // start leaking queries immediately if networkChange { - // set all upstreams to fialed and provide to performLeakingQuery + // set all upstreams to failed and provide to performLeakingQuery failedUpstreams := make(map[string]*ctrld.UpstreamConfig) for _, upstream := range p.cfg.Upstream { failedUpstreams[upstream.Name] = upstream @@ -1280,7 +1280,7 @@ func (p *prog) reinitializeOSResolver(networkChange bool) { default: mainLog.Load().Debug().Msg("initializing OS resolver") ns := ctrld.InitializeOsResolver() - mainLog.Load().Debug().Msgf("re-initialized OS resolver with nameservers: %v", ns) + mainLog.Load().Warn().Msgf("re-initialized OS resolver with nameservers: %v", ns) } select { @@ -1352,7 +1352,7 @@ func (p *prog) monitorNetworkChanges() error { validIfaces := validInterfacesMap() // log the delta for debugging - mainLog.Load().Debug(). + mainLog.Load().Warn(). Interface("old_state", delta.Old). Interface("new_state", delta.New). Msg("Network change detected") @@ -1376,14 +1376,14 @@ func (p *prog) monitorNetworkChanges() error { // Compare states directly if oldExists != newExists || oldState != newState { changed = true - mainLog.Load().Debug(). + mainLog.Load().Warn(). Str("interface", ifaceName). Str("old_state", oldState). Str("new_state", newState). Msg("Valid interface changed state") break } else { - mainLog.Load().Debug(). + mainLog.Load().Warn(). Str("interface", ifaceName). Str("old_state", oldState). Str("new_state", newState). @@ -1392,14 +1392,14 @@ func (p *prog) monitorNetworkChanges() error { } if !changed { - mainLog.Load().Debug().Msg("Ignoring interface change - no valid interfaces affected") + mainLog.Load().Warn().Msg("Ignoring interface change - no valid interfaces affected") return } if activeInterfaceExists { p.reinitializeOSResolver(true) } else { - mainLog.Load().Debug().Msg("No active interfaces found, skipping reinitialization") + mainLog.Load().Warn().Msg("No active interfaces found, skipping reinitialization") } }) diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 53662aa..7041318 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -143,8 +143,6 @@ func initLoggingWithBackup(doBackup bool) []io.Writer { multi := zerolog.MultiLevelWriter(writers...) l := mainLog.Load().Output(multi).With().Logger() mainLog.Store(&l) - // TODO: find a better way. - ctrld.ProxyLogger.Store(&l) zerolog.SetGlobalLevel(zerolog.NoticeLevel) logLevel := cfg.Service.LogLevel