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)
| 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. |
| 98 | func 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 | |
| 117 | func writeSignedInt(w io.Writer, n int64) (bool, error) { |
| 118 | var a [20]byte |