Skip to content

Commit

Permalink
add group name to log
Browse files Browse the repository at this point in the history
  • Loading branch information
jafar75 committed Dec 24, 2023
1 parent 23dea16 commit 0e1847d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ var runCmd = &cobra.Command{
SyslogPriority: cfg.GetSyslogPriority(),
RSyslogNetwork: cfg.RSyslogNetwork,
RSyslogAddress: cfg.RSyslogAddress,
Name: name,
})
}

Expand Down
4 changes: 4 additions & 0 deletions logging/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 0e1847d

Please sign in to comment.