Browse code

core: fix bad level name in new LOG()

- the syslog LOG_() used log_level_info[(level)].name (which
produced a wrong log level) instead of LOG_LEVEL2NAME(level)
- coding style fixes ( lines < 80 chars)

Andrei Pelinescu-Onciul authored on 16/02/2009 15:35:56
Showing 1 changed files
... ...
@@ -80,7 +80,8 @@
80 80
 #define L_DBG    	3
81 81
 
82 82
 #define LOG_LEVEL2NAME(level)	(log_level_info[(level) - (L_ALERT)].name)
83
-#define LOG2SYSLOG_LEVEL(level)	(log_level_info[(level) - (L_ALERT)].syslog_level)
83
+#define LOG2SYSLOG_LEVEL(level) \
84
+	(log_level_info[(level) - (L_ALERT)].syslog_level)
84 85
 
85 86
 
86 87
 /* my_pid(), process_no are from pt.h but we cannot #include it here
... ...
@@ -112,9 +113,9 @@ int log_facility_fixup(void *handle, str *name, void **val);
112 112
 /*
113 113
  * General logging macros
114 114
  *
115
- * LOG_(level, prefix, fmt, ...) prints "printf"-formatted log message to stderr (if
116
- *	`log_stderr' is non-zero) to syslog.  Note that `fmt' must be constant.
117
- *      `prefix' is added to the beginning of the message.
115
+ * LOG_(level, prefix, fmt, ...) prints "printf"-formatted log message to
116
+ * stderr (if `log_stderr' is non-zero) or to syslog.  Note that `fmt' must
117
+ * be constant. `prefix' is added to the beginning of the message.
118 118
  *
119 119
  * LOG(level, fmt, ...) is same as LOG_() with LOC_INFO prefix.
120 120
  */
... ...
@@ -143,15 +144,19 @@ int log_facility_fixup(void *handle, str *name, void **val);
143 143
 #	ifdef __SUNPRO_C
144 144
 #		define LOG_(level, prefix, fmt, ...) \
145 145
 			do { \
146
-				if (cfg_get(core, core_cfg, debug) >= (level) && DPRINT_NON_CRIT) { \
146
+				if (cfg_get(core, core_cfg, debug) >= (level) && \
147
+						DPRINT_NON_CRIT) { \
147 148
 					DPRINT_CRIT_ENTER; \
148 149
 					assert(((level) >= L_ALERT) && ((level) <= L_DBG)); \
149 150
 					if (log_stderr) { \
150 151
 						fprintf(stderr, "%2d(%d) %s: %s" fmt, \
151
-					            process_no, my_pid(), LOG_LEVEL2NAME(level), (prefix), __VA_ARGS__); \
152
+								process_no, my_pid(), LOG_LEVEL2NAME(level),\
153
+								(prefix), __VA_ARGS__); \
152 154
 					} else { \
153
-						syslog(LOG2SYSLOG_LEVEL(level) | cfg_get(core, core_cfg, log_facility), \
154
-						       "%s: %s" fmt, log_level_info[(level)].name, (prefix), __VA_ARGS__); \
155
+						syslog(LOG2SYSLOG_LEVEL(level) | \
156
+									cfg_get(core, core_cfg, log_facility), \
157
+								"%s: %s" fmt, LOG_LEVEL2NAME(level),\
158
+								(prefix), __VA_ARGS__); \
155 159
 					} \
156 160
 					DPRINT_CRIT_EXIT; \
157 161
 				} \
... ...
@@ -162,15 +167,19 @@ int log_facility_fixup(void *handle, str *name, void **val);
162 162
 #	else
163 163
 #		define LOG_(level, prefix, fmt, args...) \
164 164
 			do { \
165
-				if (cfg_get(core, core_cfg, debug) >= (level) && DPRINT_NON_CRIT) { \
165
+				if (cfg_get(core, core_cfg, debug) >= (level) && \
166
+						DPRINT_NON_CRIT) { \
166 167
 					DPRINT_CRIT_ENTER; \
167 168
 					assert(((level) >= L_ALERT) && ((level) <= L_DBG)); \
168 169
 					if (log_stderr) { \
169 170
 						fprintf(stderr, "%2d(%d) %s: %s" fmt, \
170
-					            process_no, my_pid(), LOG_LEVEL2NAME(level), (prefix), ## args); \
171
+								process_no, my_pid(), LOG_LEVEL2NAME(level),\
172
+								(prefix), ## args); \
171 173
 					} else { \
172
-						syslog(LOG2SYSLOG_LEVEL(level) | cfg_get(core, core_cfg, log_facility), \
173
-						       "%s: %s" fmt, log_level_info[(level)].name, (prefix), ## args); \
174
+						syslog(LOG2SYSLOG_LEVEL(level) |\
175
+									cfg_get(core, core_cfg, log_facility), \
176
+						 		"%s: %s" fmt, LOG_LEVEL2NAME(level),\
177
+								(prefix), ## args); \
174 178
 					} \
175 179
 					DPRINT_CRIT_EXIT; \
176 180
 				} \