mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-05-27 12:52:27 +02:00
all: eliminate usage of global ProxyLogger
So setting up logging for ctrld binary and ctrld packages could be done more easily, decouple the required setup for interactive vs daemon running. This is the first step toward replacing rs/zerolog libary with a different logging library.
This commit is contained in:
committed by
Cuong Manh Le
parent
47c04bf0f6
commit
0e66697247
@@ -27,6 +27,7 @@ type hostsFile struct {
|
||||
watcher *fsnotify.Watcher
|
||||
mu sync.Mutex
|
||||
m map[string][]string
|
||||
logger *ctrld.Logger
|
||||
}
|
||||
|
||||
// init performs initialization works, which is necessary before hostsFile can be fully operated.
|
||||
@@ -55,7 +56,7 @@ func (hf *hostsFile) refresh() error {
|
||||
// override hosts file with host_entries.conf content if present.
|
||||
hem, err := parseHostEntriesConf(hostEntriesConfPath)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
ctrld.ProxyLogger.Load().Debug().Err(err).Msg("could not read host_entries.conf file")
|
||||
hf.logger.Debug().Err(err).Msg("could not read host_entries.conf file")
|
||||
}
|
||||
for k, v := range hem {
|
||||
hf.m[k] = v
|
||||
@@ -77,14 +78,14 @@ func (hf *hostsFile) watchChanges() {
|
||||
}
|
||||
if event.Has(fsnotify.Write) || event.Has(fsnotify.Rename) || event.Has(fsnotify.Chmod) || event.Has(fsnotify.Remove) {
|
||||
if err := hf.refresh(); err != nil && !os.IsNotExist(err) {
|
||||
ctrld.ProxyLogger.Load().Err(err).Msg("hosts file changed but failed to update client info")
|
||||
hf.logger.Err(err).Msg("hosts file changed but failed to update client info")
|
||||
}
|
||||
}
|
||||
case err, ok := <-hf.watcher.Errors:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
ctrld.ProxyLogger.Load().Err(err).Msg("could not watch client info file")
|
||||
hf.logger.Err(err).Msg("could not watch client info file")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user