Why should someone write (pseudo code):
if ( logger.level == debug ){
logger.debug("do my debug log");
}
I don't see the idea behind, because the log framework would only log if the defined log level allows it.
Thanks.
I agree with your intuition that in this case there is no need for the check. Having done a quick search for reasons why someone would want to do this though, I did find: https://stackoverflow.com/a/963681/346912
Basically, that post points out that in some cases there might be an expensive computation done as part of the logging - for example creating a debug string out of a large object or collection. In which case it would make more sense to avoid that step through a conditional check.