Skip to content

slog: Disabled LogLevel is still being printed #600

@ccremer

Description

@ccremer
	backend := pterm.DefaultLogger
	logHandler := pterm.NewSlogHandler(backend.WithLevel(pterm.LogLevelDisabled))
	logger.Info("Test")

When setting the slog handler level to LogLevelDisabled, the message still gets printed.
The bug likely is caused in this if-condition:

pterm/logger.go

Lines 263 to 266 in 4048ff9

func (l Logger) print(level LogLevel, msg string, args []LoggerArgument) {
if l.Level > level {
return
}

In this condition, l.Level equals 0, which is smaller than 3 (3 = Info), so the return-clause is skipped and the message gets printed regardless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions