Closed yermulnik closed 6 months ago
https://github.com/gookit/slog/blob/master/common.go#L56-L58
// FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the
// logging level <= FatalLevel.
FatalLevel Level = 200
I'd expect Panic to panic()
, Fatal to os.Exit(1)
, and everything else to just print.
Am I misinterpreting the idea and the code?
hi @yermulnik logger.ExitFunc
is not set by default, so Fatal will not exit.
You can set it:
// for std logger
slog.SetExitFunc(os.Exit)
// for new logger
l := slog.New(func(l *slog.Logger) {
l.ExitFunc = os.Exit
})
@inhere Thanks for the pointer 👍🏻
I'm expecting
slog.Fatal
to callos.Exit(1)
to reflectlog.Fatal()
, but this is not happening. Is this expected or am I doing something incorrect?