
1 Mar
2010
1 Mar
'10
4:47 p.m.
Roland Bock wrote:
If the respective parts were header only, I wonder if the same could not be done without the MACROS (but with compiler optimization).
No. If you have a line like log (level) << Some_Expression (); there's no compiler optimization (well, probably no optimization) that can prevent Some_Expression() from being evaluated. But the macro expands to something along the lines of if (log.is_filtered (level)) {} else log.streamer () so if the line can get trivially filtered, Some_Expression (in the else clause) never gets evaluated. Assuming the filtering is fast enough, this allows you to leave TRACE level logging in a production build, and only turn it on when you really want it.