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

Callback on error level log #1328

Closed
fourier opened this issue Nov 26, 2019 · 2 comments
Closed

Callback on error level log #1328

fourier opened this issue Nov 26, 2019 · 2 comments

Comments

@fourier
Copy link

fourier commented Nov 26, 2019

Hi,

I want to add some special behavior to my application which uses spdlog: I want to have a callback after the message of log level "error" has been written.
Most of the time I want to gracefully shutdown the application and do not want to add special lines of code all the places where the ->error could be called.
Is there an easy way to achieve this? Important is that the error entry still has to be written (and flushed) to the file.

@gabime
Copy link
Owner

gabime commented Nov 26, 2019

You could develop a custom sink that does this when an error is logged, and add this to the end of the sinks vector used by your logger

@fourier
Copy link
Author

fourier commented Nov 26, 2019

Thanks! Sounds like a plan.

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