convertSlogLevel maps slog Levels to zap Levels. Note that there is some room between slog levels while zap levels are continuous, so we can't 1:1 map them. See also https://go.googlesource.com/proposal/+/master/design/56345-structured-logging.md?pli=1#levels
(l slog.Level)
| 117 | // Note that there is some room between slog levels while zap levels are continuous, so we can't 1:1 map them. |
| 118 | // See also https://go.googlesource.com/proposal/+/master/design/56345-structured-logging.md?pli=1#levels |
| 119 | func convertSlogLevel(l slog.Level) zapcore.Level { |
| 120 | switch { |
| 121 | case l >= slog.LevelError: |
| 122 | return zapcore.ErrorLevel |
| 123 | case l >= slog.LevelWarn: |
| 124 | return zapcore.WarnLevel |
| 125 | case l >= slog.LevelInfo: |
| 126 | return zapcore.InfoLevel |
| 127 | default: |
| 128 | return zapcore.DebugLevel |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | // Enabled reports whether the handler handles records at the given level. |
| 133 | func (h *Handler) Enabled(ctx context.Context, level slog.Level) bool { |