 <p>To avoid string processing, lambdas are a good solution as in the answer by Johannes Schaub. If your compiler doesn't support lambdas yet then you could do it like this with no C++0x features and no macroes:</p> <pre><code>doTrace(LEVEL_INFO, some_props) &lt;&lt; "Value of i is " &lt;&lt; i; </code></pre> <p>doTrace would return a temporary object with a virtual operator&lt;&lt;. If no tracing is to be performed, then return an object whose operator&lt;&lt; does nothing. Otherwise return an object whose operator&lt;&lt; does what you want. The destructor of the temporary object can signal that the string being outputted is done. Now destructors shouldn't throw, so if the final processing of the trace event can throw an exception, then you may need to include an end-of-event overload of operator&lt;&lt;</p> <p>This solution causes several virtual function calls even when no tracing is done, so it is less efficient than "if(tracing) ...". That should only really matter in performance critical loops where you probably want to avoid doing tracing anyway. In any case you could revert to checking tracing with an if in those cases or when the logic for doing the tracing is more complicated than comfortably fits in a sequence of &lt;&lt;'s.</p>