title: C++ variable amount of arguments with formatting for std::cout
body: <p>I used to logging in C with variable amount of arguments and formatting, and I wanna how Can I meet this in C++.</p>
  
  <p>Through Q&amp;A like this (<a href="https://stackoverflow.com/questions/29326460/how-to-make-a-variadic-macro-for-stdcout">How to make a variadic macro for std::cout?</a>), I know how to handle variable amount. But what I still do not know is, how to format, cause I can not use methods like 'setbase' between arguments now.</p>
  
  <p>For example:</p>
  
  <pre><code>// in C
  #define err(fmt, ...) (printf("[%s] "fmt"\n", __FUNCTION__, ##__VA_ARGS__))
  #define FATAL(fmt, ...) do{\
      err(fmt, ##__VA_ARGS__);\
      CLEAN_UP;\
      exit(1);\
      }while(0)
  
  int main(){
    if(1) FATAL("Just a test: 0x%lX, %d", 1, 2);
    return 0;
  }
  </code></pre>
  
  <p>"FATAL" here, accept variable amount of arguments with formatting, print them, and do some extra. I have no idea how to declare such a "FATAL" in C++.</p>