mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
cmd/cli: use warn level for network changes logging
So these events will be recorded separately from normal runtime log, making troubleshooting later more easily. While at it, only update ctrld.ProxyLogger for runCmd, it's the only one which needs to log the query when proxying requests.
This commit is contained in:
committed by
Cuong Manh Le
parent
f57972ead7
commit
eb27d1482b
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user