- 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)
... | ... |
@@ -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 | 113 |
/* |
113 | 114 |
* General logging macros |
114 | 115 |
* |
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. |
|
116 |
+ * LOG_(level, prefix, fmt, ...) prints "printf"-formatted log message to |
|
117 |
+ * stderr (if `log_stderr' is non-zero) or to syslog. Note that `fmt' must |
|
118 |
+ * be constant. `prefix' is added to the beginning of the message. |
|
118 | 119 |
* |
119 | 120 |
* LOG(level, fmt, ...) is same as LOG_() with LOC_INFO prefix. |
120 | 121 |
*/ |
... | ... |
@@ -143,15 +144,19 @@ int log_facility_fixup(void *handle, str *name, void **val); |
143 | 144 |
# ifdef __SUNPRO_C |
144 | 145 |
# define LOG_(level, prefix, fmt, ...) \ |
145 | 146 |
do { \ |
146 |
- if (cfg_get(core, core_cfg, debug) >= (level) && DPRINT_NON_CRIT) { \ |
|
147 |
+ if (cfg_get(core, core_cfg, debug) >= (level) && \ |
|
148 |
+ DPRINT_NON_CRIT) { \ |
|
147 | 149 |
DPRINT_CRIT_ENTER; \ |
148 | 150 |
assert(((level) >= L_ALERT) && ((level) <= L_DBG)); \ |
149 | 151 |
if (log_stderr) { \ |
150 | 152 |
fprintf(stderr, "%2d(%d) %s: %s" fmt, \ |
151 |
- process_no, my_pid(), LOG_LEVEL2NAME(level), (prefix), __VA_ARGS__); \ |
|
153 |
+ process_no, my_pid(), LOG_LEVEL2NAME(level),\ |
|
154 |
+ (prefix), __VA_ARGS__); \ |
|
152 | 155 |
} 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__); \ |
|
156 |
+ syslog(LOG2SYSLOG_LEVEL(level) | \ |
|
157 |
+ cfg_get(core, core_cfg, log_facility), \ |
|
158 |
+ "%s: %s" fmt, LOG_LEVEL2NAME(level),\ |
|
159 |
+ (prefix), __VA_ARGS__); \ |
|
155 | 160 |
} \ |
156 | 161 |
DPRINT_CRIT_EXIT; \ |
157 | 162 |
} \ |
... | ... |
@@ -162,15 +167,19 @@ int log_facility_fixup(void *handle, str *name, void **val); |
162 | 167 |
# else |
163 | 168 |
# define LOG_(level, prefix, fmt, args...) \ |
164 | 169 |
do { \ |
165 |
- if (cfg_get(core, core_cfg, debug) >= (level) && DPRINT_NON_CRIT) { \ |
|
170 |
+ if (cfg_get(core, core_cfg, debug) >= (level) && \ |
|
171 |
+ DPRINT_NON_CRIT) { \ |
|
166 | 172 |
DPRINT_CRIT_ENTER; \ |
167 | 173 |
assert(((level) >= L_ALERT) && ((level) <= L_DBG)); \ |
168 | 174 |
if (log_stderr) { \ |
169 | 175 |
fprintf(stderr, "%2d(%d) %s: %s" fmt, \ |
170 |
- process_no, my_pid(), LOG_LEVEL2NAME(level), (prefix), ## args); \ |
|
176 |
+ process_no, my_pid(), LOG_LEVEL2NAME(level),\ |
|
177 |
+ (prefix), ## args); \ |
|
171 | 178 |
} else { \ |
172 |
- syslog(LOG2SYSLOG_LEVEL(level) | cfg_get(core, core_cfg, log_facility), \ |
|
173 |
- "%s: %s" fmt, log_level_info[(level)].name, (prefix), ## args); \ |
|
179 |
+ syslog(LOG2SYSLOG_LEVEL(level) |\ |
|
180 |
+ cfg_get(core, core_cfg, log_facility), \ |
|
181 |
+ "%s: %s" fmt, LOG_LEVEL2NAME(level),\ |
|
182 |
+ (prefix), ## args); \ |
|
174 | 183 |
} \ |
175 | 184 |
DPRINT_CRIT_EXIT; \ |
176 | 185 |
} \ |