snapshot of https://github.com/traggo/server.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
build / build (push) Failing after 3s
Some checks failed
build / build (push) Failing after 3s
This commit is contained in:
25
config/loglevel.go
Normal file
25
config/loglevel.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
// LogLevel type that provides helper methods for decoding.
|
||||
type LogLevel zerolog.Level
|
||||
|
||||
// Decode decodes a string to a log level.
|
||||
func (ll *LogLevel) Decode(value string) error {
|
||||
if level, err := zerolog.ParseLevel(value); err == nil {
|
||||
*ll = LogLevel(level)
|
||||
return nil
|
||||
}
|
||||
*ll = LogLevel(zerolog.InfoLevel)
|
||||
return errors.New("unknown log level")
|
||||
}
|
||||
|
||||
// AsZeroLogLevel converts the LogLevel to a zerolog.Level.
|
||||
func (ll LogLevel) AsZeroLogLevel() zerolog.Level {
|
||||
return zerolog.Level(ll)
|
||||
}
|
||||
Reference in New Issue
Block a user