From 0e1847d97cfe5e7ebd143122395533ef7007de7d Mon Sep 17 00:00:00 2001 From: jafar75 Date: Mon, 25 Dec 2023 01:57:43 +0330 Subject: [PATCH] add group name to log --- cmd/run.go | 1 + logging/logger.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/cmd/run.go b/cmd/run.go index 34460f22..c67653e7 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -237,6 +237,7 @@ var runCmd = &cobra.Command{ SyslogPriority: cfg.GetSyslogPriority(), RSyslogNetwork: cfg.RSyslogNetwork, RSyslogAddress: cfg.RSyslogAddress, + Name: name, }) } diff --git a/logging/logger.go b/logging/logger.go index c52087f7..c7fbcc4f 100644 --- a/logging/logger.go +++ b/logging/logger.go @@ -35,6 +35,9 @@ type LoggerConfig struct { MaxAge int Compress bool LocalTime bool + + // group name + Name string } // NewLogger creates a new logger with the given configuration. @@ -96,6 +99,7 @@ func NewLogger(ctx context.Context, cfg LoggerConfig) zerolog.Logger { multiWriter := zerolog.MultiLevelWriter(outputs...) logger := zerolog.New(multiWriter) logger = logger.With().Timestamp().Logger() + logger = logger.With().Any("group", cfg.Name).Logger() span.End()