Project

General

Profile

Feature #896

Updated by Hammel 9 months ago

This is pretty straight forward. 

 1. In the init function:  
 <pre><code class="c"> 
     if ( log_flags & LOG_F_SYSLOG isCLIFlagSet(CLI_SYSLOG) ) 
         piboxSyslogInit(); 
 </code></pre> 

 2. In the shutdown function: 
 <pre><code class="c"> 
     if ( log_flags & LOG_F_SYSLOG isCLIFlagSet(CLI_SYSLOG) ) 
         piboxSyslogShutdown(); 
 </code></pre> 

 3. In logger local: 
 <pre><code class="c"> 
     /* ---- SYSLOG OUTPUT ---- */ 
     if ( log_flags & LOG_F_SYSLOG isCLIFlagSet(CLI_SYSLOG) ) 
     {    
         if ( verbose >= type ) 
             piboxSyslog(type, hdr, LogType[type], buf); 
     } 
 </code></pre> 

 4. Add LOG_F_SYSLOG to log.h and the comment in piboxLoggerSetFlags(). 

 5. Then add the following functions: 
 <pre><code class="c"> 

 /* 
  * These functions are separate from piboxLogger to avoid namespace clashes. 
  */ 
 void 
 piboxSyslogInit() 
 { 
     openlog("<appname>", LOG_PID, (LOG_USER | LOG_NOTICE | LOG_FACMASK)); 
 } 
 void 
 piboxSyslog( int type, const char *hdr, const char *logtype, const char *buf ) 
 { 
     syslog(SLOG[type], "%s %s %s", hdr, logtype, buf); 
 } 
 void 
 piboxSyslogShutdown() 
 { 
     closelog(); 
 } 
 </code></pre> 

 The <appname> may require additional init handling to set the name, or we can get it from the cli args.

Back