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:
Cuong Manh Le authored and Cuong Manh Le committed 2026-04-30 19:19:18 +07:00
1 parent 47c04bf0f6
commit 0e66697247
39 files changed
+425 -420

No files matched your search

+4 -2
View File
@@ -216,8 +216,9 @@ func (p *prog) registerControlServerHandler() {
return
}
loggerCtx := ctrld.LoggerCtx(context.Background(), mainLog.Load())
// Re-fetch pin code from API.
if rc, err := controld.FetchResolverConfig(cdUID, rootCmd.Version, cdDev); rc != nil {
if rc, err := controld.FetchResolverConfig(loggerCtx, cdUID, rootCmd.Version, cdDev); rc != nil {
if rc.DeactivationPin != nil {
cdDeactivationPin.Store(*rc.DeactivationPin)
} else {
@@ -321,7 +322,8 @@ func (p *prog) registerControlServerHandler() {
}
mainLog.Load().Debug().Msg("sending log file to ControlD server")
resp := logSentResponse{Size: r.size}
if err := controld.SendLogs(req, cdDev); err != nil {
loggerCtx := ctrld.LoggerCtx(context.Background(), mainLog.Load())
if err := controld.SendLogs(loggerCtx, req, cdDev); err != nil {
mainLog.Load().Error().Msgf("could not send log file to ControlD server: %v", err)
resp.Error = err.Error()
w.WriteHeader(http.StatusInternalServerError)