MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / getPrefix

Function getPrefix

cli/pkg/common/log.go:530–551  ·  view source on GitHub ↗
(logLevel zapcore.Level)

Source from the content-addressed store, hash-verified

528}
529
530func getPrefix(logLevel zapcore.Level) string {
531 t := time.Now()
532 timeStr := t.Format("2006-01-02 15:04:05.000")
533
534 levelStr := ""
535 switch logLevel {
536 case zapcore.ErrorLevel:
537 levelStr = color.Error.Sprint("ERROR") //levelStr = fmt.Sprintf("\x1b[31;1m%v\x1b[0m", "ERROR")
538 case zapcore.InfoLevel:
539 levelStr = color.Info.Sprint("INFO") // fmt.Sprintf("\x1b[34;1m%s\x1b[0m", "INFO")
540 case zapcore.FatalLevel:
541 levelStr = color.BgRed.Sprint("FATAL") //fmt.Sprintf("\x1b[31;1m%s\x1b[0m", "FATAL")
542 case zapcore.PanicLevel:
543 levelStr = color.BgLightRed.Sprint("FATAL")
544 case zapcore.WarnLevel:
545 levelStr = color.Warn.Sprint("WARNING") //levelStr = fmt.Sprintf("\x1b[36;1m%s\x1b[0m", "WARNING")
546 case zapcore.DebugLevel:
547 levelStr = color.Debug.Sprint("DEBUG") //levelStr = fmt.Sprintf("\x1b[34;1m%s\x1b[0m", "DEBUG")
548 }
549
550 return fmt.Sprintf("%v %v ", timeStr, levelStr)
551}

Callers 6

ErrorMethod · 0.85
FatalMethod · 0.85
InfoMethod · 0.85
DebugMethod · 0.85
ImportanceMethod · 0.85
WarningMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected