Skip to content

Commit

Permalink
config: use string for log level
Browse files Browse the repository at this point in the history
  • Loading branch information
zekroTJA committed Jul 21, 2023
1 parent 66227b7 commit fa6c3dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cmd/shinpuru/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,11 @@ func main() {
log.Fatal().Err(err).Msg("Failed to parse config")
}

log.SetLevel(level.Level(cfg.Config().Logging.LogLevel))
lvl, ok := level.LevelFromString(cfg.Config().Logging.LogLevel)
if !ok {
log.Fatal().Msgf("invalid log level: %s", cfg.Config().Logging.LogLevel)
}
log.SetLevel(lvl)

if lokiCfg := cfg.Config().Logging.Loki; lokiCfg.Enabled {
w, err := lokiwriter.NewWriter(lokiCfg.Options)
Expand Down
4 changes: 2 additions & 2 deletions internal/models/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var DefaultConfig = Config{
},
Logging: Logging{
CommandLogging: true,
LogLevel: 4,
LogLevel: "info",
},
TwitchApp: TwitchApp{},
Storage: StorageType{
Expand Down Expand Up @@ -179,7 +179,7 @@ type LokiLogging struct {
// main logger.
type Logging struct {
CommandLogging bool `json:"commandlogging"`
LogLevel int `json:"loglevel"`
LogLevel string `json:"loglevel"` // can be string or int
Loki LokiLogging `json:"loki"`
}

Expand Down

0 comments on commit fa6c3dc

Please sign in to comment.