From c2b9132a7e933a68df4cc0eb86aab23719ded1b5 Mon Sep 17 00:00:00 2001 From: Teppei Fukuda Date: Sun, 2 Jun 2024 15:41:55 +0400 Subject: [PATCH] fix(cli): always output fatal errors to stderr (#6827) Signed-off-by: knqyf263 --- pkg/log/logger.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/log/logger.go b/pkg/log/logger.go index efee7ef8800d..f46eb46fc87f 100644 --- a/pkg/log/logger.go +++ b/pkg/log/logger.go @@ -67,7 +67,8 @@ func Errorf(format string, args ...any) { slog.Default().Error(fmt.Sprintf(forma // Fatal for logging fatal errors func Fatal(msg string, args ...any) { - slog.Default().Log(context.Background(), LevelFatal, msg, args...) + // Fatal errors should be logged to stderr even if the logger is disabled. + New(NewHandler(os.Stderr, &Options{})).Log(context.Background(), LevelFatal, msg, args...) os.Exit(1) }