c - Is there a way to redirect syslog messages to stdout? -


i have application can run in 2 modes, either cli, or daemon.

i using syslog() logging. however, when run in cli mode i'd logging, except marked log_debug, messages sent console instead of logged.

i have tried use setlogmask(), doesn't seem redirect console.

what best way this?

as suggested in comments maverik, wrote wrapper around syslog determines whether send output log or console. here in case ever needs this.

void mylog (int level, const char *format, ...) {     va_list args;     va_start (args, format);      if (remote)     {         vsyslog(level, format, args);     }        else     {         if (level == log_debug)             vsyslog(level, format, args);         else             vprintf(format, args);     }     va_end(args); } 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -