Skip to content

Commit

Permalink
exclude CSV loggers from logging error logs in signal handler when us…
Browse files Browse the repository at this point in the history
…ing CsvWriter
  • Loading branch information
odygrd committed Sep 24, 2024
1 parent e5e0272 commit 96e1f92
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions include/quill/backend/SignalHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ class SignalHandlerContext
~SignalHandlerContext() = default;
};

#define QUILL_SIGNAL_HANDLER_LOG(logger, log_level, fmt, ...) \
do \
{ \
if (logger->template should_log_statement<log_level>()) \
{ \
static constexpr quill::MacroMetadata macro_metadata{ \
#define QUILL_SIGNAL_HANDLER_LOG(logger, log_level, fmt, ...) \
do \
{ \
if (logger->template should_log_statement<log_level>()) \
{ \
static constexpr quill::MacroMetadata macro_metadata{ \
"SignalHandler:~", "", fmt, nullptr, log_level, quill::MacroMetadata::Event::Log}; \
\
logger->template log_statement<false, false>(quill::LogLevel::None, &macro_metadata, ##__VA_ARGS__); \
} \
} \
} while (0)

/***/
Expand Down Expand Up @@ -138,7 +138,8 @@ void on_signal(int32_t signal_number)
else
{
// This means signal handler is running on a frontend thread, we can log and flush
LoggerBase* logger_base = detail::LoggerManager::instance().get_valid_logger(SignalHandlerContext::excluded_logger_name_substr);
LoggerBase* logger_base =
detail::LoggerManager::instance().get_valid_logger(SignalHandlerContext::excluded_logger_name_substr);

if (logger_base)
{
Expand Down Expand Up @@ -250,7 +251,8 @@ BOOL WINAPI on_console_signal(DWORD signal)
(signal == CTRL_C_EVENT || signal == CTRL_BREAK_EVENT))
{
// Log the interruption and flush log messages
LoggerBase* logger_base = detail::LoggerManager::instance().get_valid_logger(SignalHandlerContext::excluded_logger_name_substr);
LoggerBase* logger_base =
detail::LoggerManager::instance().get_valid_logger(SignalHandlerContext::excluded_logger_name_substr);
if (logger_base)
{
auto logger = reinterpret_cast<LoggerImpl<TFrontendOptions>*>(logger_base);
Expand All @@ -277,7 +279,8 @@ LONG WINAPI on_exception(EXCEPTION_POINTERS* exception_p)
if ((backend_thread_id != 0) && (current_thread_id != backend_thread_id))
{
// Log the interruption and flush log messages
LoggerBase* logger_base = detail::LoggerManager::instance().get_valid_logger(SignalHandlerContext::excluded_logger_name_substr);
LoggerBase* logger_base =
detail::LoggerManager::instance().get_valid_logger(SignalHandlerContext::excluded_logger_name_substr);
if (logger_base)
{
auto logger = reinterpret_cast<LoggerImpl<TFrontendOptions>*>(logger_base);
Expand Down

0 comments on commit 96e1f92

Please sign in to comment.