MCPcopy Index your code
hub / github.com/coder/slog / bracketedLevel

Function bracketedLevel

internal/entryhuman/entry.go:98–115  ·  view source on GitHub ↗

bracketedLevel is an optimization to avoid extra allocations and calls to strings.ToLower when we want to translate/print the lowercase version of a log level.

(l slog.Level)

Source from the content-addressed store, hash-verified

96// bracketedLevel is an optimization to avoid extra allocations and calls to strings.ToLower
97// when we want to translate/print the lowercase version of a log level.
98func bracketedLevel(l slog.Level) string {
99 switch l {
100 case slog.LevelDebug:
101 return "[debu]"
102 case slog.LevelInfo:
103 return "[info]"
104 case slog.LevelWarn:
105 return "[warn]"
106 case slog.LevelError:
107 return "[erro]"
108 case slog.LevelCritical:
109 return "[crit]"
110 case slog.LevelFatal:
111 return "[fata]"
112 default:
113 return "[unkn]"
114 }
115}
116
117func writeSignedInt(w io.Writer, n int64) (bool, error) {
118 var a [20]byte

Callers 1

FmtMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected