]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
Added priority strings in output and color
authorhadaq <hadaq>
Thu, 1 Aug 2002 09:28:48 +0000 (09:28 +0000)
committerhadaq <hadaq>
Thu, 1 Aug 2002 09:28:48 +0000 (09:28 +0000)
BUGBUG: LOG_NDEBUG not effective any more

compat/syslog.c

index 58eb62fd811638d355c6339703d92f58cd47cce4..4207aa924419e00d5653bdd99f7d910c1afec3cd 100644 (file)
@@ -1,37 +1,59 @@
-#include <syslog.h>
+static char *rcsId = "$Header:";
+
 #include <string.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <syslog.h>
 
 #define OUR_IDENT_LEN 256
 
 static unsigned ourMaskpri = 0xffffffff;
-static unsigned ourLogopt = 0;
 static char ourIdent[OUR_IDENT_LEN] = "";
+static unsigned ourLogopt = 0;
+static unsigned ourFacility = LOG_USER;
 
 void SYSLOG_syslog(int priority, const char *message, ...) {
        va_list ap;
+       static const char *pri = "PACEWNID";
+       char idPri[OUR_IDENT_LEN + 3];
+       static const char *mode[] = {
+               "\033[0;1m\033[43;31m",
+               "\033[0;1m\033[43;39m",
+               "\033[43;39m",
+               "\033[0;1m\033[49;31m",
+               "\033[0;1m",
+               "\033[0;1m\033[49;32m",
+               "",
+               "",
+               "\033[49;39m\033[0m"
+       };
+
+       sprintf(idPri, "%s<%c>", ourIdent, pri[priority]);
+
        if ((ourLogopt & LOG_PERROR) && (ourMaskpri & (1 << priority))) {
-               fprintf(stderr, "%s: ", ourIdent);
+               fprintf(stderr, "%s", mode[priority]);
+               fprintf(stderr, "%s: ", idPri);
                va_start(ap, message);
                vfprintf(stderr, message, ap);
                va_end(ap);
+               fprintf(stderr, "%s", mode[LOG_DEBUG + 1]);
                fprintf(stderr, "%c", '\n');
        }
 
+       openlog(idPri, ourLogopt & ~LOG_PERROR, ourFacility);
        va_start(ap, message);
        vsyslog(priority, message, ap);
        va_end(ap);
+       closelog();
 }
 
 void SYSLOG_openlog(const char *ident, int logopt, int facility) {
        strncpy(ourIdent, ident, OUR_IDENT_LEN-1);
        ourLogopt = logopt;
-       openlog(ident, logopt, facility);
+       ourFacility = facility;
 }
 
 void SYSLOG_closelog(void) {
-       closelog();
 }
 
 int  SYSLOG_setlogmask(int maskpri) {