Skip to content
New issue

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

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

Already on GitHub? # to your account

Added doc on how to handle logrus.Fatalf events #501

Merged
merged 6 commits into from
Dec 7, 2022

Conversation

Mindstan
Copy link
Contributor

This PR adds some doc on how to handle logrus.Fatalf events.

When calling logrus.Fatalf(), logrus calls os.Exit(1) immediately after treating the log. They are two consequences :

  • all defer are ignored;
  • it is almost certain that Sentry will not have time to send the fatal event to the remote server before the program stops.

Fortunately, logrus.RegisterExitHandler allows to run arbitrary code before the call to os.Exit. I propose to add it to the logrus example.

example/logrus/main.go Outdated Show resolved Hide resolved
example/logrus/main.go Show resolved Hide resolved
example/logrus/main.go Outdated Show resolved Hide resolved
example/logrus/main.go Outdated Show resolved Hide resolved
@cleptric
Copy link
Member

cleptric commented Dec 6, 2022

@Mindstan Ping 🙂

Mindstan and others added 5 commits December 7, 2022 13:42
Co-authored-by: Michi Hoffmann <cleptric@users.noreply.github.com>
Co-authored-by: Michi Hoffmann <cleptric@users.noreply.github.com>
Co-authored-by: Michi Hoffmann <cleptric@users.noreply.github.com>
@cleptric cleptric merged commit 90e63f2 into getsentry:master Dec 7, 2022
@cleptric
Copy link
Member

cleptric commented Dec 7, 2022

Thank you! 🚀

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants