feat: logging

This commit is contained in:
Fu Diwei
2025-03-16 18:43:54 +08:00
parent 65b199d392
commit c13a7a7873
3 changed files with 233 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
package logging
import "log/slog"
type Level string
const (
LevelDebug Level = "DEBUG"
LevelInfo Level = "INFO"
LevelWarn Level = "WARN"
LevelError Level = "ERROR"
)
func (l Level) String() string {
return string(l)
}
func (l Level) Level() slog.Level {
switch l {
case LevelDebug:
return slog.LevelDebug
case LevelInfo:
return slog.LevelInfo
case LevelWarn:
return slog.LevelWarn
case LevelError:
return slog.LevelError
default:
return slog.Level(-1)
}
}