]> mj.ucw.cz Git - libucw.git/commitdiff
Allow modules to change the log title, second attempt.
authorTomas Valla <tom@ucw.cz>
Tue, 23 Dec 2003 00:18:53 +0000 (00:18 +0000)
committerTomas Valla <tom@ucw.cz>
Tue, 23 Dec 2003 00:18:53 +0000 (00:18 +0000)
lib/lib.h
lib/log.c

index 518ce1956de19c52083c5b8f4c4c72914b7e9f57..de3c21c136b655b4dadf4bbe240dbfe4aed5d530 100644 (file)
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -48,6 +48,8 @@
 #define L_ERROR_R      'e'
 #define L_FATAL                '!'             /* die() */
 
+extern char *log_title;                        /* NULL - print no title, default is log_progname */
+
 void log_msg(unsigned int cat, const char *msg, ...) __attribute__((format(printf,2,3)));
 #define log log_msg
 void die(byte *, ...) NONRET;
index ae8648c25a7c69782abd18eba132e751826dbca9..5d132da40b6fbdeb22f9885dd87998909461b993 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -18,8 +18,8 @@
 #include <time.h>
 #include <alloca.h>
 
-char log_progname[32];
-static char *log_name_patt, *log_name;
+static char log_progname[32], *log_name_patt, *log_name;
+char *log_title = log_progname;
 static pid_t log_pid;
 static int log_params;
 static int log_name_size;
@@ -73,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
        {