Currently the checkLevel() method in Logger is a private level method, but it would be useful to expose this method as public.
It can be useful to determine the current log level before making a potentially costly-to-construct log string (which might not even be logged depening on the current log level.
Currently this can be done using the getLevel() method, like so...
// only log if DEBUG level logging or higher is currently enabled
if (this->logger->getLevel() <= Logger::Level::LL_DEBUG)
{
// do the stuff
}
...but if the the checkLevel() method were exposed as a public method it would be a little "cleaner" from a redability point of view, and additionally one does not need to be aware of the internal ordering of the log levels defined in the enum (lowest->highest, or highest->lowest?) in order to do the correct <= or => numeric comparison:
// only log if DEBUG level logging or higher is currently enabled
if ( this->logger->checkLevel(Logger::Level::LL_DEBUG) )
{
// do the stuff
}
Currently the checkLevel() method in Logger is a private level method, but it would be useful to expose this method as public.
It can be useful to determine the current log level before making a potentially costly-to-construct log string (which might not even be logged depening on the current log level.
Currently this can be done using the getLevel() method, like so...
// only log if DEBUG level logging or higher is currently enabledif (this->logger->getLevel() <= Logger::Level::LL_DEBUG){// do the stuff}...but if the the checkLevel() method were exposed as a public method it would be a little "cleaner" from a redability point of view, and additionally one does not need to be aware of the internal ordering of the log levels defined in the enum (lowest->highest, or highest->lowest?) in order to do the correct <= or => numeric comparison:
// only log if DEBUG level logging or higher is currently enabledif ( this->logger->checkLevel(Logger::Level::LL_DEBUG) ){// do the stuff}