title: How can I map linux syslog to printf in C
body: <p>I have a linux application running on my desk top, and I wanted to redirect the syslog() calls to printf() calls. </p>
  
  <p><strong>Note:</strong> I do <em>not</em> want to replace the calls, just redirect</p>
  
  <p>So I wrote some code to do this:</p>
  
  <pre><code>#ifndef EMBED
  #define syslog(level, stuff) printf("SYSLOG: %s\n", stuff)
  #endif
  </code></pre>
  
  <p>Works great in the one file where I was using it. I moved this to a new file and got an error:</p>
  
  <pre><code>error: macro "syslog" passed 3 arguments, but takes just 2
  </code></pre>
  
  <p>I know the error is because the calls in the new file are mixed, some are using 2 arguments to syslog, some are using 3. I also know I need to somehow redirect this via variable argument lists, but how exactly do I do this? I haven't gotten it working yet...</p>
  
  <p>As I understand it, syslog() and printf() should be:</p>
  
  <pre><code>void syslog(int priority, const char *format, ...)
  int printf(const char *format, ...)
  </code></pre>
  
  <p>So I tried:</p>
  
  <pre><code>#define ERR 3
  #ifndef EMBED         // This is not defined in my env, btw
  #define syslog(pri, fmt, ...) printf(fmt, ...)
  #endif
  ...
  void main() {
  ...
  syslog(ERR, "test");
  </code></pre>
  
  <p>but that gives the error:</p>
  
  <pre><code>error: expected expression before ‘...’ token
  </code></pre>
  
  <p>Suggestions on how this macro should look/be used?</p>