Browse code

core: new maro LOG__(...) to allow overwriting default name for log level

- LOG_(...) is pinting to it now

Daniel-Constantin Mierla authored on 19/03/2014 21:06:21
Showing 1 changed files
... ...
@@ -163,10 +163,12 @@ void dprint_term_color(char f, char b, str *obuf);
163 163
 #ifdef NO_LOG
164 164
 
165 165
 #	ifdef __SUNPRO_C
166
+#		define LOG__(facility, level, lname, prefix, fmt, ...)
166 167
 #		define LOG_(facility, level, prefix, fmt, ...)
167 168
 #		define LOG(level, fmt, ...)
168 169
 #		define LOG_FC(facility, level, fmt, ...)
169 170
 #	else
171
+#		define LOG__(facility, level, lname, prefix, fmt, args...)
170 172
 #		define LOG_(facility, level, prefix, fmt, args...)
171 173
 #		define LOG(level, fmt, args...)
172 174
 #		define LOG_FC(facility, level, fmt, args...)
... ...
@@ -185,7 +187,7 @@ void dprint_term_color(char f, char b, str *obuf);
185 187
 #	endif
186 188
 
187 189
 #	ifdef __SUNPRO_C
188
-#		define LOG_(facility, level, prefix, fmt, ...) \
190
+#		define LOG__(facility, level, lname, prefix, fmt, ...) \
189 191
 			do { \
190 192
 				if (unlikely(get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \
191 193
 						DPRINT_NON_CRIT)) { \
... ...
@@ -195,7 +197,7 @@ void dprint_term_color(char f, char b, str *obuf);
195 197
 							if (unlikely(log_color)) dprint_color(level); \
196 198
 							fprintf(stderr, "%2d(%d) %s: %s" fmt, \
197 199
 									process_no, my_pid(), \
198
-									LOG_LEVEL2NAME(level), (prefix), \
200
+									(lname)?(lname):LOG_LEVEL2NAME(level), (prefix), \
199 201
 									__VA_ARGS__); \
200 202
 							if (unlikely(log_color)) dprint_color_reset(); \
201 203
 						} else { \
... ...
@@ -203,7 +205,8 @@ void dprint_term_color(char f, char b, str *obuf);
203 205
 								   (((facility) != DEFAULT_FACILITY) ? \
204 206
 									(facility) : \
205 207
 									cfg_get(core, core_cfg, log_facility)), \
206
-									"%s: %s" fmt, LOG_LEVEL2NAME(level),\
208
+									"%s: %s" fmt, \
209
+									(lname)?(lname):LOG_LEVEL2NAME(level),\
207 210
 									(prefix), __VA_ARGS__); \
208 211
 						} \
209 212
 					} else { \
... ...
@@ -231,7 +234,10 @@ void dprint_term_color(char f, char b, str *obuf);
231 234
 					DPRINT_CRIT_EXIT; \
232 235
 				} \
233 236
 			} while(0)
234
-			
237
+
238
+#		define LOG_(facility, level, lname, prefix, fmt, ...) \
239
+	LOG__(facility, level, NULL, prefix, fmt, __VA_ARGS__)
240
+
235 241
 #		ifdef LOG_FUNC_NAME
236 242
 #			define LOG(level, fmt, ...) \
237 243
 	LOG_(DEFAULT_FACILITY, (level), LOC_INFO, "%s(): " fmt,\
... ...
@@ -251,7 +257,7 @@ void dprint_term_color(char f, char b, str *obuf);
251 257
 #		endif /* LOG_FUNC_NAME */
252 258
 
253 259
 #	else /* ! __SUNPRO_C */
254
-#		define LOG_(facility, level, prefix, fmt, args...) \
260
+#		define LOG__(facility, level, lname, prefix, fmt, args...) \
255 261
 			do { \
256 262
 				if (get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \
257 263
 						DPRINT_NON_CRIT) { \
... ...
@@ -261,7 +267,7 @@ void dprint_term_color(char f, char b, str *obuf);
261 267
 							if (unlikely(log_color)) dprint_color(level); \
262 268
 							fprintf(stderr, "%2d(%d) %s: %s" fmt, \
263 269
 									process_no, my_pid(), \
264
-									LOG_LEVEL2NAME(level), \
270
+									(lname)?(lname):LOG_LEVEL2NAME(level), \
265 271
 									(prefix) , ## args);\
266 272
 							if (unlikely(log_color)) dprint_color_reset(); \
267 273
 						} else { \
... ...
@@ -269,7 +275,8 @@ void dprint_term_color(char f, char b, str *obuf);
269 275
 								   (((facility) != DEFAULT_FACILITY) ? \
270 276
 									(facility) : \
271 277
 									cfg_get(core, core_cfg, log_facility)), \
272
-									"%s: %s" fmt, LOG_LEVEL2NAME(level),\
278
+									"%s: %s" fmt,\
279
+									(lname)?(lname):LOG_LEVEL2NAME(level),\
273 280
 									(prefix) , ## args); \
274 281
 						} \
275 282
 					} else { \
... ...
@@ -297,7 +304,10 @@ void dprint_term_color(char f, char b, str *obuf);
297 304
 					DPRINT_CRIT_EXIT; \
298 305
 				} \
299 306
 			} while(0)
300
-			
307
+
308
+#		define LOG_(facility, level, prefix, fmt, args...) \
309
+	LOG__(facility, level, NULL, prefix, fmt, ## args)
310
+
301 311
 #		ifdef LOG_FUNC_NAME
302 312
 #			define LOG(level, fmt, args...) \
303 313
 	LOG_(DEFAULT_FACILITY, (level), LOC_INFO, "%s(): " fmt ,\