fix(cli): always output fatal errors to stderr (#6827)

Signed-off-by: knqyf263 <knqyf263@gmail.com>
This commit is contained in:
Teppei Fukuda
2024-06-02 15:41:55 +04:00
committed by GitHub
parent aa0c413814
commit c2b9132a7e

View File

@@ -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)
}