sirupsen / logrus

Structured, pluggable logging for Go.
MIT License
24.8k stars 2.27k forks source link

`entry.Log(logrus.FatalLevel, "fatal level")` doesn't call `logger.Exit(1)` #1345

Closed dlsrb6342 closed 2 years ago

dlsrb6342 commented 2 years ago
fatelei commented 2 years ago

in entry.log only level <= PanicLevel will lead to panic

image

FatalLevel is bigger than PanicLevel

image
dlsrb6342 commented 2 years ago

I mean System.Exit(1) not panic. As second picture that you attatched, FatalLevel should calls logger.Exit(1)

fatelei commented 2 years ago

I mean System.Exit(1) not panic. As second picture that you attatched, FatalLevel should calls logger.Exit(1)

I have check the code,this is a demo,work as expect.

dlsrb6342 commented 2 years ago

check this demo. As I described in issue, I call entry.Log(log.FatalLevel, "fatal") but it didn't call System.Exit(1)

fatelei commented 2 years ago

i read the code

Maybe this is by design @sirupsen

Anyway, if this is a bug, i can fix it

dgsb commented 2 years ago

This is not a bug. It works as documented:

~/src/logrus$ go doc . Entry.Log
package logrus // import "github.com/sirupsen/logrus"

func (entry *Entry) Log(level Level, args ...interface{})
    Log will log a message at the level given as parameter. Warning: using Log
    at Panic or Fatal level will not respectively Panic nor Exit. For this
    behaviour Entry.Panic or Entry.Fatal should be used instead.