-added support for fake LOG_NONE syslog facility that disables syslogging completely
authorTomas Mandys <tomas.mandys@iptel.org>
Fri, 25 Aug 2006 15:27:08 +0000 (15:27 +0000)
committerTomas Mandys <tomas.mandys@iptel.org>
Fri, 25 Aug 2006 15:27:08 +0000 (15:27 +0000)
daemonize.c
dprint.c
dprint.h

index 2e5c948..b0c8a09 100644 (file)
@@ -198,7 +198,8 @@ int daemonize(char*  name)
        }
        
        if (log_stderr==0)
-               openlog(name, LOG_PID|LOG_CONS, log_facility);
+               if (log_facility!=LOG_NONE)
+                       openlog(name, LOG_PID|LOG_CONS, log_facility);
                /* LOG_CONS, LOG_PERRROR ? */
 
        return  0;
index 124fe00..e62dbbf 100644 (file)
--- a/dprint.c
+++ b/dprint.c
@@ -45,15 +45,17 @@ static char* str_fac[]={"LOG_AUTH","LOG_CRON","LOG_DAEMON",
 #ifndef __OS_solaris
                                        "LOG_AUTHPRIV","LOG_FTP","LOG_SYSLOG",
 #endif
+                                       "LOG_NONE",
                                        0};
 static int int_fac[]={LOG_AUTH ,  LOG_CRON , LOG_DAEMON ,
                                        LOG_KERN , LOG_LOCAL0 , LOG_LOCAL1 ,
                                        LOG_LOCAL2 , LOG_LOCAL3 , LOG_LOCAL4 , LOG_LOCAL5 ,
                                        LOG_LOCAL6 , LOG_LOCAL7 , LOG_LPR , LOG_MAIL ,
-                                       LOG_NEWS , LOG_USER , LOG_UUCP
+                                       LOG_NEWS , LOG_USER , LOG_UUCP,
 #ifndef __OS_solaris
-                                       ,LOG_AUTHPRIV,LOG_FTP,LOG_SYSLOG
+                                       LOG_AUTHPRIV,LOG_FTP,LOG_SYSLOG,
 #endif
+                                       LOG_NONE
                                        };
 
 
index e8332b8..6f7da80 100644 (file)
--- a/dprint.h
+++ b/dprint.h
@@ -32,6 +32,8 @@
 
 #include <syslog.h>
 
+/* define non existing facility to disable logging */
+#define LOG_NONE (~LOG_FACMASK)
 
 #define L_ALERT -3
 #define L_CRIT  -2
@@ -91,7 +93,7 @@ int str2facility(char *s);
                                        if (log_stderr){ \
                                                dprint (__VA_ARGS__); \
                                        }else{ \
-                                               syslog(DPRINT_LEV|log_facility,  __VA_ARGS__); \
+                                               if (log_facility!=LOG_NONE) syslog(DPRINT_LEV|log_facility,  __VA_ARGS__); \
                                        }\
                                } \
                        }while(0)
@@ -102,7 +104,7 @@ int str2facility(char *s);
                                        if (log_stderr){ \
                                                dprint (fmt, ## args); \
                                        }else{ \
-                                               syslog(DPRINT_LEV|log_facility, fmt, ## args); \
+                                               if (log_facility!=LOG_NONE) syslog(DPRINT_LEV|log_facility, fmt, ## args); \
                                        }\
                                } \
                        }while(0)
@@ -126,7 +128,7 @@ int str2facility(char *s);
                        do { \
                                if (debug>=(lev)){ \
                                        if (log_stderr) dprint (__VA_ARGS__); \
-                                       else { \
+                                       else if (log_facility!=LOG_NONE) { \
                                                switch(lev){ \
                                                        case L_CRIT: \
                                                                syslog(LOG_CRIT|log_facility, __VA_ARGS__); \
@@ -158,7 +160,7 @@ int str2facility(char *s);
                        do { \
                                if (debug>=(lev)){ \
                                        if (log_stderr) dprint (fmt, ## args); \
-                                       else { \
+                                       else if (log_facility!=LOG_NONE) { \
                                                switch(lev){ \
                                                        case L_CRIT: \
                                                                syslog(LOG_CRIT|log_facility, fmt, ##args); \