As I recall it is to allow the code to just entirely not exist for logging levels that you do not want, so the code is never even called and incurs no speed penalty, thus you only pay for the logging levels that you are actively logging.
How much is this actually used in production systems? I am assuming that while you may want to change the logging level at runtime you don’t always have the luxury of being able to recompile and reload code. (though I have seen some smart tricks to work around this)
This of course very much depends on the type of system you are running.
There are different levels of logging, as in there is the actual logged level given to an output (and there can be many outputs, such as a remote server, local file, stdout, whatever), and there is the ‘compiled’ level, of which anything below is stripped out at compile time. That is usually good to strip out especially noisy levels like debug (I keep info and higher in prod).
The answer on stack overflow is correct. It is a macro so it gets metadata about the caller, such as file, line, module, function, app, etc. This metadata may be logged and it may be used in the future for tracing/filtering.
That was the original motivation anyway. The compile time purging came later.