diff --git a/cns/common/service.go b/cns/common/service.go index f37d3bba1a..8301790a5a 100644 --- a/cns/common/service.go +++ b/cns/common/service.go @@ -10,6 +10,7 @@ import ( acn "github.com/Azure/azure-container-networking/common" "github.com/Azure/azure-container-networking/server/tls" "github.com/Azure/azure-container-networking/store" + "go.uber.org/zap" ) // Service implements behavior common to all services. @@ -20,6 +21,7 @@ type Service struct { ErrChan chan<- error Store store.KeyValueStore ChannelMode string + Logger *zap.Logger } // ServiceAPI defines base interface. @@ -41,6 +43,7 @@ type ServiceConfig struct { Server server ChannelMode string TLSSettings tls.TlsSettings + Logger *zap.Logger } // server struct to store primaryInterfaceIP from VM, port where customer provides by -p and temporary flag EnableLocalServer @@ -80,6 +83,7 @@ func (service *Service) Initialize(config *ServiceConfig) error { service.Store = config.Store service.Version = config.Version service.ChannelMode = config.ChannelMode + service.Logger = config.Logger logger.Debugf("[Azure CNS] nitialized service: %+v with config: %+v.", service, config) diff --git a/cns/service/main.go b/cns/service/main.go index df1fc67453..d9e747f9ec 100644 --- a/cns/service/main.go +++ b/cns/service/main.go @@ -646,6 +646,7 @@ func main() { } host, _ := os.Hostname() z = z.With(zap.String("hostname", host), zap.String("version", version), zap.String("kubernetes_apiserver", os.Getenv("KUBERNETES_SERVICE_HOST"))) + config.Logger = z.With(zap.String("module", "cns service")) // Set the v2 logger to the global logger if v2 logger enabled. if cnsconfig.EnableLoggerV2 { logger.Printf("hotswapping logger v2") //nolint:staticcheck // ignore new deprecation