]> mj.ucw.cz Git - libucw.git/blobdiff - lib/log.c
Including <stdarg.h> in lib/lib.h enables us to finally export vlog_msg()
[libucw.git] / lib / log.c
index e6260b601fe8f34e2772ed1955c0719cac4758e6..381f7257830c453e32b5a28b83cffaae15fdc75b 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -19,7 +19,8 @@
 #include <alloca.h>
 
 static char log_progname[32], *log_name_patt, *log_name;
-static pid_t log_pid;
+char *log_title;
+static int log_pid;
 static int log_params;
 static int log_name_size;
 static int log_switching;
@@ -57,8 +58,8 @@ log_switch(struct tm *tm)
   log_switching--;
 }
 
-static void
-vlog(unsigned int cat, const char *msg, va_list args)
+void
+vlog_msg(unsigned int cat, const char *msg, va_list args)
 {
   time_t tim = time(NULL);
   struct tm *tm = localtime(&tim);
@@ -72,12 +73,12 @@ vlog(unsigned int cat, const char *msg, va_list args)
       p = buf = alloca(buflen);
       *p++ = cat;
       p += strftime(p, buflen, " %Y-%m-%d %H:%M:%S ", tm);
-      if (log_progname[0])
+      if (log_title)
        {
          if (log_pid)
-           p += sprintf(p, "[%s (%d)] ", log_progname, log_pid);
+           p += sprintf(p, "[%s (%d)] ", log_title, log_pid);
          else
-           p += sprintf(p, "[%s] ", log_progname);
+           p += sprintf(p, "[%s] ", log_title);
        }
       else
        {
@@ -111,7 +112,7 @@ log_msg(unsigned int cat, const char *msg, ...)
   va_list args;
 
   va_start(args, msg);
-  vlog(cat, msg, args);
+  vlog_msg(cat, msg, args);
   va_end(args);
 }
 
@@ -121,7 +122,7 @@ die(byte *msg, ...)
   va_list args;
 
   va_start(args, msg);
-  vlog(L_FATAL, msg, args);
+  vlog_msg(L_FATAL, msg, args);
   va_end(args);
 #ifdef DEBUG_DIE_BY_ABORT
   abort();
@@ -163,6 +164,7 @@ log_init(byte *argv0)
     {
       strncpy(log_progname, log_basename(argv0), sizeof(log_progname)-1);
       log_progname[sizeof(log_progname)-1] = 0;
+      log_title = log_progname;
     }
 }