MCPcopy
hub / github.com/cortexlabs/cortex / DefaultZapConfig

Function DefaultZapConfig

pkg/lib/logging/logging.go:67–91  ·  view source on GitHub ↗
(level userconfig.LogLevel, fields ...map[string]interface{})

Source from the content-addressed store, hash-verified

65}
66
67func DefaultZapConfig(level userconfig.LogLevel, fields ...map[string]interface{}) zap.Config {
68 encoderConfig := zap.NewProductionEncoderConfig()
69 encoderConfig.MessageKey = "message"
70
71 labels := map[string]interface{}{}
72 for _, m := range fields {
73 for k, v := range m {
74 labels[k] = v
75 }
76 }
77
78 initialFields := map[string]interface{}{}
79 if len(labels) > 0 {
80 initialFields["cortex.labels"] = labels
81 }
82
83 return zap.Config{
84 Level: zap.NewAtomicLevelAt(userconfig.ToZapLogLevel(level)),
85 Encoding: "json",
86 EncoderConfig: encoderConfig,
87 OutputPaths: []string{"stdout"},
88 ErrorOutputPaths: []string{"stderr"},
89 InitialFields: initialFields,
90 }
91}

Callers 2

initializeLoggerFunction · 0.92
initializeLoggerFunction · 0.85

Calls 1

ToZapLogLevelFunction · 0.92

Tested by

no test coverage detected