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

Calling logrus.Log with logrus.FatalLevel should behave as logrus.Fatal #993

Closed
clafoutis42 opened this issue Jul 22, 2019 · 6 comments
Closed

Comments

@clafoutis42
Copy link

I made an error wrapper for my project that embeds the logging level wanted for the error.
Therefore I have a method that calls logrus.Log(level, "error description"), and I was surprised that if level is equal to logrus.FatalLevel, logrus.Log won't exit as logrus.Fatal would.
Is this the wanted behavior ? If so, why ?

@pradykaushik
Copy link

Sorry for not getting to this sooner.
You are right that logrus.Log(logrus.FatalLevel, args...) does not exit.
AFAIK, this shouldn't be the intended behavior and entry.log(...) is missing a check.

if level == FatalLevel {
  entry.Logger.Exit(1)
}

@freeformz what are your thoughts on this?

@freeformz
Copy link
Collaborator

Either logrus.Log(logrus.{Fatal,Panic}Level,...) should log at that level and not panic / error or it log at that level and panic/error. ATM passing PanicLevel will cause a panic, but passing FataLevel will not: https://play.golang.org/p/nGDL1sBOkuD

Maybe @sirupsen or @dgsb can weigh in on which direction is the error, otherwise I'm going to have to review the git history to see if it indicates the intent.

FWIW: My inclination atm would be to make Log(logrus.{Fatal,Panic}Level,...), not exit/panic. This would resolve #1028. My reasoning behind that is that logrus should allow some way to log at panic/fatal level w/o actually panicing/exiting, but that the .Panic/Fatal methods should absolutely continue to panic/exit. Research may change that opinion.

@jonmchan
Copy link

I would appreciate that @freeformz !

@dgsb
Copy link
Collaborator

dgsb commented Oct 25, 2019

@freeformz I'm not sure what was the initial intent, but we cannot change the behaviour. That would be a breaking change for v1 users.
We should indeed improve the documentation so that it's very clear on what is the expected behaviour.

@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants