title: how to exclude method if compilation symbol is not set? how to pass variable number of parameters and format them in function body?
body: <p>I wrote my own simple class for logging. I understand that I better to use some kind of library (boost.log, log4cpp?) but let's anyway discuss my simple class:</p>
  
  <pre><code>#include "stdafx.h"
  #include "Logger.h"
  
  
  Logger::Logger(std::string fileName)
  {
      logFile.open(fileName);
  }
  
  
  Logger::~Logger(void)
  {
      logFile.close();
  }
  
  
  void Logger::Error(std::string message) {
      logFile &lt;&lt; message &lt;&lt; std::endl;
  }
  
  void Logger::Debug(std::string message) {
      logFile &lt;&lt; message &lt;&lt; std::endl;
  }
  </code></pre>
  
  <ol>
  <li>I want my methods to accept variable number of arguments, so I can pass parameters like that <code>"Error code: %x", code</code>. How to do that?</li>
  <li>I want <code>Debug</code> method to be excluded if <code>LOG_DEBUG</code> compilation symbol is not set. in C# I can just add <code>[Conditional("LOG_DEBUG")]</code> before the method declaration, but now to do that in c++?</li>
  </ol>
  
  <p><strong>upd</strong> Regarding 1 i've tried that and it works:</p>
  
  <pre><code>void Logger::Debug(std::string message, ...) {
  va_list arglist;
  fprintf(pFile, message.c_str(), arglist);
  </code></pre>