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

Add a dedicated Hook for Fatal calls #591

Open
LorisFriedel opened this issue Sep 28, 2023 · 1 comment
Open

Add a dedicated Hook for Fatal calls #591

LorisFriedel opened this issue Sep 28, 2023 · 1 comment

Comments

@LorisFriedel
Copy link

Hello!

I'm currently converting all my projects from logrus to zerolog (thank you guys for the amazing library!) and I was wondering if it would be possible to add a dedicated Hook associated to Fatal call, something that would help cleanup things properly if a Fatal call happens.

Logrus has https://github.com/sirupsen/logrus/blob/master/alt_exit.go#L74 (DeferExitHandler) and it's very handy for when the Go program has CLI interface that manipulate the terminal in such way a cleanup is needed if the program exit for example.

I know I can do it with the Hook system already, but I feel like this special use-case would:

  1. improve performances compared to setting-up a classic Hook
  2. make sense to have a dedicated hook because of the nature of the Fatal call
  3. be easier to use and setup overall for this kind of use-cases

What do you think?

@roachadam
Copy link

roachadam commented Oct 21, 2023

+1 for this. I'm struggling to get the zerolog hook to behave in the same manner as needed from logrus.

I can get it to work with normal logs, but using Fatal/Panic, the hooks will always execute before the write

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

No branches or pull requests

2 participants