]> mj.ucw.cz Git - libucw.git/blobdiff - lib/log.c
Defined a GET_TAGGED_CHAR macro to read our internal representation
[libucw.git] / lib / log.c
index f2440e803917303f6952c778eeee0bf061078302..0f51f3c3736a5c1d3cebbacb5e81039bde40af48 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
 #include <unistd.h>
 #include <sys/time.h>
 
-static byte *log_progname;
+static char *log_progname;
 static pid_t log_pid;
 
 void
 log_fork(void)
 {
-  log_pid = 0;
+  log_pid = getpid();
 }
 
 static void
-vlog(unsigned int cat, byte *msg, va_list args)
+vlog(unsigned int cat, const char *msg, va_list args)
 {
   time_t tim = time(NULL);
   struct tm *tm = localtime(&tim);
   char buf[32];
 
-  if (!log_pid)
-    log_pid = getpid();
   strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm);
   fprintf(stderr, "%c %s ", cat, buf);
   if (log_progname)
-    fprintf(stderr, "[%s (%d)] ", log_progname, log_pid);
+    {
+      if (log_pid)
+       fprintf(stderr, "[%s (%d)] ", log_progname, log_pid);
+      else
+       fprintf(stderr, "[%s] ", log_progname);
+    }
+  else
+    {
+      if (log_pid)
+       fprintf(stderr, "[%d] ", log_pid);
+    }
   vfprintf(stderr, msg, args);
   fputc('\n', stderr);
   fflush(stderr);
 }
 
 void
-log(unsigned int cat, byte *msg, ...)
+log(unsigned int cat, const char *msg, ...)
 {
   va_list args;