title: Trace logging using #define to avoid a performance issue
body: <p>I have to trace log a very performance critical part of my application. And it has to be configurable in production.</p>
  
  <p>I came up with this thing, but something about it seems like a bad idea.</p>
  
  <pre><code>#define TRACE(X) if(log-&gt;trace) {log-&gt;traceLog(X);}
  </code></pre>
  
  <p>The <code>log-&gt;trace</code> is a bool so it should be fairly cheap in branch prediction, it is going to be used something like this:</p>
  
  <pre><code>TRACE("Input channel: " + std::to_string(ChannelNumber) + " [r] " +
            std::to_string(ChannelValue-&gt;LongReal))
  </code></pre>
  
  <p>Creating a string and converting all sorts of stuff to log is expensive and a log method call which would check inside if trace log level is disabled would do just that.</p>
  
  <p>Is there a better way to doing this? Am I approaching trace logging entirely in a wrong way? </p>