Skip to content

Commit

Permalink
Expose Disabled level
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed Jun 30, 2024
1 parent 0545cb7 commit b23725f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion level.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ var (
Warning = Level{3}
Error = Level{4}
Critical = Level{5}
disabled = Level{6} // It shouldn't be possible to define a message at this level.
// It shouldn't be possible to define a message at this level. Filtering at this level should
// mean no messages ever get through.
Disabled = Level{6}
)

func (l Level) isNotSet() bool {
Expand Down
2 changes: 1 addition & 1 deletion reporting-rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func parseRuleString(s string) (_ Rule, ok bool, _ error) {
level, ok, err = levelFromString(ss[1])
if !ok {
// blah= means disable the name, but just blah means to always include it
level = disabled
level = Disabled
}
if err != nil {
return nil, false, fmt.Errorf("parsing level %q: %w", ss[1], err)
Expand Down
2 changes: 1 addition & 1 deletion slog.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func toSlogLevel(level Level) (slog.Level, bool) {
return slog.LevelError, true
case Critical:
return slog.LevelError + 1, true
case disabled:
case Disabled:
return slog.LevelDebug - 1, false
default:
panic(level)
Expand Down

0 comments on commit b23725f

Please sign in to comment.