[BACK]Return to log.c CVS log [TXT][DIR] Up to [local] / blind

Diff for /blind/log.c between version 1.1 and 1.4

version 1.1, 2022/03/17 09:09:26 version 1.4, 2022/03/18 09:20:46
Line 1 
Line 1 
 /*  /*
  * Copyright (c) 2022 Daniel Kroczynski <d@kroczynski.net>  1;95;0c * Copyright (c) 2022 Daniel Kroczynski <d@kroczynski.net>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 14 
Line 14 
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
   
   #include <stdio.h>
 #include <stdarg.h>  #include <stdarg.h>
 #include <syslog.h>  #include <syslog.h>
 #include <time.h>  #include <time.h>
   
   static int  log_background;
 static int  log_verbose;  static int  log_verbose;
 const char *log_procname;  const char *log_procname;
   
 void log_init(int, int);  void log_init(int, int);
 void log_setv(int);  void log_setv(int);
 int  log_getv(void);  int  log_getv(void);
   void log_send(const char *, va_list)
           __attribute__((__format__ (printf, 1, 0)));
 void log_info(const char *, ...)  void log_info(const char *, ...)
         __attribute__((__format__ (printf, 1, 2)));          __attribute__((__format__ (printf, 1, 2)));
 void log_debug(const char *, ...)  void log_debug(const char *, ...)
Line 37  log_init(int background, int facility)
Line 41  log_init(int background, int facility)
         if (__progname != NULL)          if (__progname != NULL)
                 log_procname = __progname;                  log_procname = __progname;
   
         if (background)          log_background = background;
           if (log_background)
                 openlog(log_procname, LOG_PID | LOG_NDELAY, facility);                  openlog(log_procname, LOG_PID | LOG_NDELAY, facility);
   
         tzset();          tzset();
Line 56  log_getv(void)
Line 61  log_getv(void)
 }  }
   
 void  void
   log_send(const char *info, va_list ap)
   {
           if (log_background)
                   vsyslog(LOG_INFO, info, ap);
           else {
                   vfprintf(stderr, info, ap);
                   fprintf(stderr, "\n");
           }
   }
   
   void
 log_info(const char *info, ...)  log_info(const char *info, ...)
 {  {
         va_list ap;          va_list ap;
   
         va_start(ap, info);          va_start(ap, info);
         vsyslog(LOG_INFO, info, ap);          log_send(info, ap);
         va_end(ap);          va_end(ap);
 }  }
   
Line 72  log_debug(const char *info, ...)
Line 88  log_debug(const char *info, ...)
   
         if (log_verbose) {          if (log_verbose) {
                 va_start(ap, info);                  va_start(ap, info);
                 vsyslog(LOG_INFO, info, ap);                  log_send(info, ap);
                 va_end(ap);                  va_end(ap);
         }          }
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

https://cvs.kroczynski.net