diff --git a/pkg/logging/logging.go b/pkg/logging/logging.go index 50c6fe36..33578389 100644 --- a/pkg/logging/logging.go +++ b/pkg/logging/logging.go @@ -43,6 +43,14 @@ func WithOutputPaths(paths []string) Option { } } +// WithInitialFields allows the logger to be configured with static fields at creation time. +// This is useful for setting fields that are constant across all log messages. +func WithInitialFields(fields map[string]interface{}) Option { + return func(c *zap.Config) { + c.InitialFields = fields + } +} + // Init creates a new zap logger and attaches it to the provided context. func Init(ctx context.Context, opts ...Option) (context.Context, error) { zc := zap.NewProductionConfig()