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 185
 #	endif
186 186
 
187 187
 #	ifdef __SUNPRO_C
188
-#		define LOG_(facility, level, prefix, fmt, ...) \
188
+#		define LOG__(facility, level, lname, prefix, fmt, ...) \
189 189
 			do { \
190 190
 				if (unlikely(get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \
191 191
 						DPRINT_NON_CRIT)) { \
... ...
@@ -195,7 +197,7 @@ void dprint_term_color(char f, char b, str *obuf);
195 195
 							if (unlikely(log_color)) dprint_color(level); \
196 196
 							fprintf(stderr, "%2d(%d) %s: %s" fmt, \
197 197
 									process_no, my_pid(), \
198
-									LOG_LEVEL2NAME(level), (prefix), \
198
+									(lname)?(lname):LOG_LEVEL2NAME(level), (prefix), \
199 199
 									__VA_ARGS__); \
200 200
 							if (unlikely(log_color)) dprint_color_reset(); \
201 201
 						} else { \
... ...
@@ -203,7 +205,8 @@ void dprint_term_color(char f, char b, str *obuf);
203 203
 								   (((facility) != DEFAULT_FACILITY) ? \
204 204
 									(facility) : \
205 205
 									cfg_get(core, core_cfg, log_facility)), \
206
-									"%s: %s" fmt, LOG_LEVEL2NAME(level),\
206
+									"%s: %s" fmt, \
207
+									(lname)?(lname):LOG_LEVEL2NAME(level),\
207 208
 									(prefix), __VA_ARGS__); \
208 209
 						} \
209 210
 					} else { \
... ...
@@ -231,7 +234,10 @@ void dprint_term_color(char f, char b, str *obuf);
231 231
 					DPRINT_CRIT_EXIT; \
232 232
 				} \
233 233
 			} while(0)
234
-			
234
+
235
+#		define LOG_(facility, level, lname, prefix, fmt, ...) \
236
+	LOG__(facility, level, NULL, prefix, fmt, __VA_ARGS__)
237
+
235 238
 #		ifdef LOG_FUNC_NAME
236 239
 #			define LOG(level, fmt, ...) \
237 240
 	LOG_(DEFAULT_FACILITY, (level), LOC_INFO, "%s(): " fmt,\
... ...
@@ -251,7 +257,7 @@ void dprint_term_color(char f, char b, str *obuf);
251 251
 #		endif /* LOG_FUNC_NAME */
252 252
 
253 253
 #	else /* ! __SUNPRO_C */
254
-#		define LOG_(facility, level, prefix, fmt, args...) \
254
+#		define LOG__(facility, level, lname, prefix, fmt, args...) \
255 255
 			do { \
256 256
 				if (get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \
257 257
 						DPRINT_NON_CRIT) { \
... ...
@@ -261,7 +267,7 @@ void dprint_term_color(char f, char b, str *obuf);
261 261
 							if (unlikely(log_color)) dprint_color(level); \
262 262
 							fprintf(stderr, "%2d(%d) %s: %s" fmt, \
263 263
 									process_no, my_pid(), \
264
-									LOG_LEVEL2NAME(level), \
264
+									(lname)?(lname):LOG_LEVEL2NAME(level), \
265 265
 									(prefix) , ## args);\
266 266
 							if (unlikely(log_color)) dprint_color_reset(); \
267 267
 						} else { \
... ...
@@ -269,7 +275,8 @@ void dprint_term_color(char f, char b, str *obuf);
269 269
 								   (((facility) != DEFAULT_FACILITY) ? \
270 270
 									(facility) : \
271 271
 									cfg_get(core, core_cfg, log_facility)), \
272
-									"%s: %s" fmt, LOG_LEVEL2NAME(level),\
272
+									"%s: %s" fmt,\
273
+									(lname)?(lname):LOG_LEVEL2NAME(level),\
273 274
 									(prefix) , ## args); \
274 275
 						} \
275 276
 					} else { \
... ...
@@ -297,7 +304,10 @@ void dprint_term_color(char f, char b, str *obuf);
297 297
 					DPRINT_CRIT_EXIT; \
298 298
 				} \
299 299
 			} while(0)
300
-			
300
+
301
+#		define LOG_(facility, level, prefix, fmt, args...) \
302
+	LOG__(facility, level, NULL, prefix, fmt, ## args)
303
+
301 304
 #		ifdef LOG_FUNC_NAME
302 305
 #			define LOG(level, fmt, args...) \
303 306
 	LOG_(DEFAULT_FACILITY, (level), LOC_INFO, "%s(): " fmt ,\