Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slog: Disabled LogLevel is still being printed #600

Closed
ccremer opened this issue Dec 28, 2023 · 3 comments · Fixed by #601
Closed

slog: Disabled LogLevel is still being printed #600

ccremer opened this issue Dec 28, 2023 · 3 comments · Fixed by #601
Labels
bug Something isn't working

Comments

@ccremer
Copy link

ccremer commented Dec 28, 2023

	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.

@ccremer ccremer added the bug Something isn't working label Dec 28, 2023
@MarvinJWendt
Copy link
Member

Thanks for reporting the issue! I'll take a look :)

@MarvinJWendt
Copy link
Member

MarvinJWendt commented Dec 29, 2023

Fix released in v0.12.73 🚀

@ccremer
Copy link
Author

ccremer commented Dec 30, 2023

That was fast! Thanks 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants