34 lines
691 B
Go
34 lines
691 B
Go
package log
|
|
|
|
import "fmt"
|
|
|
|
type PlainLoggerLogLevel LogLevel
|
|
|
|
func (level PlainLoggerLogLevel) String() (out string) {
|
|
switch level {
|
|
case PlainLoggerLogLevel(LevelInfo):
|
|
out = "[info]"
|
|
case PlainLoggerLogLevel(LevelWarn):
|
|
out = "[warn]"
|
|
case PlainLoggerLogLevel(LevelError):
|
|
out = "[error]"
|
|
case PlainLoggerLogLevel(LevelDebug):
|
|
out = "[debug]"
|
|
}
|
|
return
|
|
}
|
|
|
|
type PlainLogger struct{}
|
|
|
|
func NewPlainLogger() *PlainLogger {
|
|
return &PlainLogger{}
|
|
}
|
|
|
|
func (p *PlainLogger) Log(level LogLevel, msg string) {
|
|
fmt.Printf("%s %s\n", PlainLoggerLogLevel(level), msg)
|
|
}
|
|
|
|
func (p *PlainLogger) Logf(level LogLevel, format string, a ...any) {
|
|
p.Log(level, fmt.Sprintf(format, a...))
|
|
}
|