Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dlsrb6342 opened this issue Aug 2, 2022 · 6 comments
Closed
Labels

Comments

@dlsrb6342
Copy link

  • I found a bug that entry.Log doesn't call logger.Exit(1).
  • If I call entry.Log with logrus.FatalLevel, system doesn't exit.
@fatelei
Copy link

fatelei commented Aug 9, 2022

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

image

FatalLevel is bigger than PanicLevel

image

@dlsrb6342
Copy link
Author

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

@fatelei
Copy link

fatelei commented Aug 9, 2022

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
Copy link
Author

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

@fatelei
Copy link

fatelei commented Aug 9, 2022

i read the code

  • call entry.Fatal this function will call entry.logger.Exit
  • call entry.Log, this function only panic when level <= PanicLevel, so it with FatalLevel will not exit program.

Maybe this is by design @sirupsen

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

@dgsb dgsb added the invalid label Aug 12, 2022
@dgsb
Copy link
Collaborator

dgsb commented Aug 12, 2022

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.

@dgsb dgsb closed this as completed Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants