console-slog
console-slog copied to clipboard
Debug logs are treated as errors
I copied the exact example from the README:
package main
import (
"errors"
"log/slog"
"os"
"github.com/phsym/console-slog"
)
func main() {
logger := slog.New(
console.NewHandler(os.Stderr, &console.HandlerOptions{Level: slog.LevelDebug}),
)
slog.SetDefault(logger)
slog.Info("Hello world!", "foo", "bar")
slog.Debug("Debug message")
slog.Warn("Warning message")
slog.Error("Error message", "err", errors.New("the error"))
logger = logger.With("foo", "bar").
WithGroup("the-group").
With("bar", "baz")
logger.Info("group info", "attr", "value")
}
and the Debug level log is output with red text as if it's an error.. it seems like attributes are always considered errors as well:
The issue appears to be with using os.Stderr as the output writer.. Switching that to os.Stdout resolves the improper coloring: