quill icon indicating copy to clipboard operation
quill copied to clipboard

Add QUILL_SHOULD_LOG macro

Open fhriley opened this issue 1 year ago • 0 comments

Currently, to conditionally do some processing before logging, you do it like this:

if (logger->should_log(LogLevel::TraceL1)) {
  ... // do some processing
  LOG_TRACE_L1(logger, ...);
}

If QUILL_ACTIVE_LOG_LEVEL is set to QUILL_LOG_LEVEL_DEBUG or higher, the LOG_TRACE_L1 will not be compiled in, but the remaining code will be. It seems like there should be a macro instead such that the code above becomes:

if (QUILL_SHOULD_LOG(logger, LogLevel::TraceL1)) {
  ... // do some processing
  LOG_TRACE_L1(logger, ...);
}

The macro would just evaluate to false when QUILL_ACTIVE_LOG_LEVEL is set to QUILL_LOG_LEVEL_DEBUG or higher.

fhriley avatar Aug 24 '22 16:08 fhriley