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

Function initializeLogger

pkg/operator/operator/logging.go:78–102  ·  view source on GitHub ↗
(key string, level userconfig.LogLevel, fields map[string]interface{})

Source from the content-addressed store, hash-verified

76}
77
78func initializeLogger(key string, level userconfig.LogLevel, fields map[string]interface{}) (*zap.SugaredLogger, error) {
79 loggerConfig := logging.DefaultZapConfig(level, fields)
80
81 disableJSONLogging := strings.ToLower(os.Getenv("CORTEX_DISABLE_JSON_LOGGING"))
82 if disableJSONLogging == "true" {
83 loggerConfig.Encoding = "console"
84 }
85
86 logger, err := loggerConfig.Build()
87 if err != nil {
88 return nil, errors.WithStack(err)
89 }
90
91 sugarLogger := logger.Sugar()
92
93 _loggerCache.Lock()
94 defer _loggerCache.Unlock()
95
96 _loggerCache.m[key] = &cachedLogger{
97 lastAccess: time.Now(),
98 value: sugarLogger,
99 }
100
101 return sugarLogger, nil
102}
103
104func GetRealtimeAPILogger(apiName string, apiID string) (*zap.SugaredLogger, error) {
105 loggerCacheKey := fmt.Sprintf("apiName=%s,apiID=%s", apiName, apiID)

Callers 4

GetRealtimeAPILoggerFunction · 0.70
GetJobLoggerFunction · 0.70
GetJobLoggerFromSpecFunction · 0.70

Calls 2

DefaultZapConfigFunction · 0.92
WithStackFunction · 0.92

Tested by

no test coverage detected