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

Function initializeLogger

pkg/lib/logging/logging.go:31–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29var loggerLock sync.Mutex
30
31func initializeLogger() {
32 logLevel := strings.ToLower(os.Getenv("CORTEX_LOG_LEVEL"))
33 if logLevel == "" {
34 logLevel = "info"
35 }
36
37 cortexLogLevel := userconfig.LogLevelFromString(logLevel)
38 if cortexLogLevel == userconfig.UnknownLogLevel {
39 panic(ErrorInvalidLogLevel(logLevel, userconfig.LogLevelTypes()))
40 }
41
42 zapConfig := DefaultZapConfig(cortexLogLevel)
43
44 disableJSONLogging := strings.ToLower(os.Getenv("CORTEX_DISABLE_JSON_LOGGING"))
45 if disableJSONLogging == "true" {
46 zapConfig.Encoding = "console"
47 }
48
49 zapLogger, err := zapConfig.Build()
50 if err != nil {
51 panic(err)
52 }
53
54 logger = zapLogger.Sugar()
55}
56
57func GetLogger() *zap.SugaredLogger {
58 loggerLock.Lock()

Callers 1

GetLoggerFunction · 0.70

Calls 4

LogLevelFromStringFunction · 0.92
LogLevelTypesFunction · 0.92
ErrorInvalidLogLevelFunction · 0.85
DefaultZapConfigFunction · 0.85

Tested by

no test coverage detected