Skip to content

Commit

Permalink
fix: default log level
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Jan 27, 2024
1 parent 1d3de33 commit 221aaf4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions logcore/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ type LogLevel string
func (l LogLevel) ToStr() string { return string(l) }

const (
LEVEL_DEBUG LogLevel = "DEBUG"
LEVEL_INFO LogLevel = "INFO"
LEVEL_WARN LogLevel = "WARN"
LEVEL_ERROR LogLevel = "ERROR"
LEVEL_FATAL LogLevel = "FATAL"
LEVEL_DEBUG LogLevel = "DEBUG"
LEVEL_INFO LogLevel = "INFO"
LEVEL_WARN LogLevel = "WARN"
LEVEL_ERROR LogLevel = "ERROR"
LEVEL_FATAL LogLevel = "FATAL"
LEVEL_DEFAULT_WARN LogLevel = ""
)

func LevelToInt(level LogLevel) int {
Expand All @@ -24,6 +25,8 @@ func LevelToInt(level LogLevel) int {
return 40
case LEVEL_FATAL:
return 50
case LEVEL_DEFAULT_WARN:
return 30
}
panic("not supported log level")
}
Expand Down
2 changes: 1 addition & 1 deletion logcore/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func WithLogLevel(log_level_str LogLevel) LoggerParam {
programLevel.Set(slog.LevelWarn)
case LEVEL_ERROR:
programLevel.Set(slog.LevelError)
case "":
case LEVEL_DEFAULT_WARN:
programLevel.Set(slog.LevelWarn)
default:
panic(fmt.Sprintf("invalid log level=%s for logger=%s", log_level_str, logger.name))
Expand Down

0 comments on commit 221aaf4

Please sign in to comment.