diff --git a/cmd/run.go b/cmd/run.go index 3101c645..5af40ec5 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/cmd/run_test.go b/cmd/run_test.go index f104e1e7..ebaae822 100644 --- a/cmd/run_test.go +++ b/cmd/run_test.go @@ -38,7 +38,7 @@ func Test_runCmd(t *testing.T) { runCmd.Print(output) // Check if GatewayD started and stopped correctly. assert.Contains(t, output, "GatewayD is running") - assert.Contains(t, output, "Stopped all servers\n") + assert.Contains(t, output, "Stopped all servers") waitGroup.Done() }(&waitGroup) @@ -94,7 +94,7 @@ func Test_runCmdWithTLS(t *testing.T) { // Check if GatewayD started and stopped correctly. assert.Contains(t, output, "GatewayD is running") assert.Contains(t, output, "TLS is enabled") - assert.Contains(t, output, "Stopped all servers\n") + assert.Contains(t, output, "Stopped all servers") waitGroup.Done() }(&waitGroup) @@ -147,11 +147,11 @@ func Test_runCmdWithMultiTenancy(t *testing.T) { runCmd.Print(output) // Check if GatewayD started and stopped correctly. assert.Contains(t, output, "GatewayD is running") - assert.Contains(t, output, "There are clients available in the pool count=10 name=default") - assert.Contains(t, output, "There are clients available in the pool count=10 name=test") + assert.Contains(t, output, "There are clients available in the pool count=10 group=default") + assert.Contains(t, output, "There are clients available in the pool count=10 group=test") assert.Contains(t, output, "GatewayD is listening address=0.0.0.0:15432") assert.Contains(t, output, "GatewayD is listening address=0.0.0.0:15433") - assert.Contains(t, output, "Stopped all servers\n") + assert.Contains(t, output, "Stopped all servers") waitGroup.Done() }(&waitGroup) @@ -227,7 +227,7 @@ func Test_runCmdWithCachePlugin(t *testing.T) { runCmd.Print(output) // Check if GatewayD started and stopped correctly. assert.Contains(t, output, "GatewayD is running") - assert.Contains(t, output, "Stopped all servers\n") + assert.Contains(t, output, "Stopped all servers") waitGroup.Done() }(&waitGroup) diff --git a/logging/logger.go b/logging/logger.go index c52087f7..1048ff4d 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().Str("group", cfg.Name).Logger() span.End()