Browse code

-added support for fake LOG_NONE syslog facility that disables syslogging completely

Tomas Mandys authored on 25/08/2006 15:27:08
Showing 3 changed files
... ...
@@ -198,7 +198,8 @@ int daemonize(char*  name)
198 198
 	}
199 199
 	
200 200
 	if (log_stderr==0)
201
-		openlog(name, LOG_PID|LOG_CONS, log_facility);
201
+		if (log_facility!=LOG_NONE)
202
+			openlog(name, LOG_PID|LOG_CONS, log_facility);
202 203
 		/* LOG_CONS, LOG_PERRROR ? */
203 204
 
204 205
 	return  0;
... ...
@@ -45,15 +45,17 @@ static char* str_fac[]={"LOG_AUTH","LOG_CRON","LOG_DAEMON",
45 45
 #ifndef __OS_solaris
46 46
 					"LOG_AUTHPRIV","LOG_FTP","LOG_SYSLOG",
47 47
 #endif
48
+					"LOG_NONE",
48 49
 					0};
49 50
 static int int_fac[]={LOG_AUTH ,  LOG_CRON , LOG_DAEMON ,
50 51
 					LOG_KERN , LOG_LOCAL0 , LOG_LOCAL1 ,
51 52
 					LOG_LOCAL2 , LOG_LOCAL3 , LOG_LOCAL4 , LOG_LOCAL5 ,
52 53
 					LOG_LOCAL6 , LOG_LOCAL7 , LOG_LPR , LOG_MAIL ,
53
-					LOG_NEWS , LOG_USER , LOG_UUCP
54
+					LOG_NEWS , LOG_USER , LOG_UUCP,
54 55
 #ifndef __OS_solaris
55
-					,LOG_AUTHPRIV,LOG_FTP,LOG_SYSLOG
56
+					LOG_AUTHPRIV,LOG_FTP,LOG_SYSLOG,
56 57
 #endif
58
+					LOG_NONE
57 59
 					};
58 60
 
59 61
 
... ...
@@ -32,6 +32,8 @@
32 32
 
33 33
 #include <syslog.h>
34 34
 
35
+/* define non existing facility to disable logging */
36
+#define LOG_NONE (~LOG_FACMASK)
35 37
 
36 38
 #define L_ALERT -3
37 39
 #define L_CRIT  -2
... ...
@@ -91,7 +93,7 @@ int str2facility(char *s);
91 93
 					if (log_stderr){ \
92 94
 						dprint (__VA_ARGS__); \
93 95
 					}else{ \
94
-						syslog(DPRINT_LEV|log_facility,  __VA_ARGS__); \
96
+						if (log_facility!=LOG_NONE) syslog(DPRINT_LEV|log_facility,  __VA_ARGS__); \
95 97
 					}\
96 98
 				} \
97 99
 			}while(0)
... ...
@@ -102,7 +104,7 @@ int str2facility(char *s);
102 104
 					if (log_stderr){ \
103 105
 						dprint (fmt, ## args); \
104 106
 					}else{ \
105
-						syslog(DPRINT_LEV|log_facility, fmt, ## args); \
107
+						if (log_facility!=LOG_NONE) syslog(DPRINT_LEV|log_facility, fmt, ## args); \
106 108
 					}\
107 109
 				} \
108 110
 			}while(0)
... ...
@@ -126,7 +128,7 @@ int str2facility(char *s);
126 128
 			do { \
127 129
 				if (debug>=(lev)){ \
128 130
 					if (log_stderr) dprint (__VA_ARGS__); \
129
-					else { \
131
+					else if (log_facility!=LOG_NONE) { \
130 132
 						switch(lev){ \
131 133
 							case L_CRIT: \
132 134
 								syslog(LOG_CRIT|log_facility, __VA_ARGS__); \
... ...
@@ -158,7 +160,7 @@ int str2facility(char *s);
158 160
 			do { \
159 161
 				if (debug>=(lev)){ \
160 162
 					if (log_stderr) dprint (fmt, ## args); \
161
-					else { \
163
+					else if (log_facility!=LOG_NONE) { \
162 164
 						switch(lev){ \
163 165
 							case L_CRIT: \
164 166
 								syslog(LOG_CRIT|log_facility, fmt, ##args); \