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

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

version 1.4, 2022/03/18 09:20:46 version 1.5, 2022/03/18 19:55:19
Line 15 
Line 15 
  */   */
   
 #include <stdio.h>  #include <stdio.h>
   #include <stdlib.h>
 #include <stdarg.h>  #include <stdarg.h>
 #include <syslog.h>  #include <syslog.h>
   #include <string.h>
   #include <errno.h>
 #include <time.h>  #include <time.h>
   
 static int  log_background;  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_initialize(int, int);
 void log_setv(int);  void    log_setverbose(int);
 int  log_getv(void);  int     log_getverbose(void);
 void log_send(const char *, va_list)  void    log_send(const char *, va_list)
         __attribute__((__format__ (printf, 1, 0)));          __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 *, ...)
         __attribute__((__format__ (printf, 1, 2)));          __attribute__((__format__ (printf, 1, 2)));
   __dead void log_fatal(const char *, ...)
           __attribute__((__format__ (printf, 1, 2)));
   
 void  void
 log_init(int background, int facility)  log_initialize(int background, int facility)
 {  {
         extern char *__progname;          extern char *__progname;
   
Line 49  log_init(int background, int facility)
Line 54  log_init(int background, int facility)
 }  }
   
 void  void
 log_setv(int verb)  log_setverbose(int verb)
 {  {
         log_verbose = verb;          log_verbose = verb;
 }  }
   
 int  int
 log_getv(void)  log_getverbose(void)
 {  {
         return (log_verbose);          return (log_verbose);
 }  }
Line 63  log_getv(void)
Line 68  log_getv(void)
 void  void
 log_send(const char *info, va_list ap)  log_send(const char *info, va_list ap)
 {  {
         if (log_background)          if (info != NULL) {
                 vsyslog(LOG_INFO, info, ap);                  if (log_background)
         else {                          vsyslog(LOG_INFO, info, ap);
                 vfprintf(stderr, info, ap);                  else {
                 fprintf(stderr, "\n");                          vfprintf(stderr, info, ap);
                           fprintf(stderr, "\n");
                   }
         }          }
 }  }
   
Line 92  log_debug(const char *info, ...)
Line 99  log_debug(const char *info, ...)
                 va_end(ap);                  va_end(ap);
         }          }
 }  }
   
   void
   log_fatal(const char *info, ...)
   {
           va_list ap;
   
           va_start(ap, info);
           log_send(info, ap);
           va_end(ap);
           log_info("%s", strerror(errno));
           exit(1);
   }
   

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

https://cvs.kroczynski.net