Browse code

core: fix logging macros for Solaris Studio

(cherry picked from commit 5244959b3089370e5df01d26e77d31211fce9370)

Spencer Thomason authored on 24/06/2016 07:20:13 • Daniel-Constantin Mierla committed on 27/06/2016 13:48:31
Showing 1 changed files
... ...
@@ -184,11 +184,11 @@ void log_prefix_init(void);
184 184
 #ifdef NO_LOG
185 185
 
186 186
 #	ifdef __SUNPRO_C
187
-#		define LOG__(facility, level, lname, prefix, fmt, ...)
188
-#		define LOG_(facility, level, prefix, fmt, ...)
187
+#		define LOG__(facility, level, lname, prefix, ...)
188
+#		define LOG_(facility, level, prefix, ...)
189 189
 #		define LOG(level, fmt, ...)
190
-#		define LOG_FC(facility, level, fmt, ...)
191
-#		define LOG_LN(level, lname, fmt, ...)
190
+#		define LOG_FC(facility, level, ...)
191
+#		define LOG_LN(level, lname, ...)
192 192
 #	else
193 193
 #		define LOG__(facility, level, lname, prefix, fmt, args...)
194 194
 #		define LOG_(facility, level, prefix, fmt, args...)
... ...
@@ -212,78 +212,78 @@ void log_prefix_init(void);
212 212
 #	ifdef __SUNPRO_C
213 213
 #		define LOG__(facility, level, lname, prefix, fmt, ...) \
214 214
 			do { \
215
-				if (unlikely(get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \
216
-						DPRINT_NON_CRIT)) { \
215
+				if (get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \
216
+						DPRINT_NON_CRIT) { \
217
+					int __llevel; \
218
+					__llevel = ((level)<L_ALERT)?L_ALERT:(((level)>L_DBG)?L_DBG:level); \
217 219
 					DPRINT_CRIT_ENTER; \
218
-					if (likely(((level) >= L_ALERT) && ((level) <= L_DBG))){ \
219
-						if (unlikely(log_stderr)) { \
220
-							if (unlikely(log_color)) dprint_color(level); \
221
-							fprintf(stderr, "%2d(%d) %s: %s" fmt, \
222
-									process_no, my_pid(), \
223
-									(lname)?(lname):LOG_LEVEL2NAME(level), (prefix), \
224
-									__VA_ARGS__); \
225
-							if (unlikely(log_color)) dprint_color_reset(); \
220
+					if (unlikely(log_stderr)) { \
221
+						if (unlikely(log_color)) dprint_color(__llevel); \
222
+						if(unlikely(log_prefix_val)) { \
223
+							fprintf(stderr, "%.*s%2d(%d) %s: %s" fmt, \
224
+								log_prefix_val->len, log_prefix_val->s, \
225
+								process_no, my_pid(), \
226
+								(lname)?(lname):LOG_LEVEL2NAME(__llevel), \
227
+								(prefix) , __VA_ARGS__);\
226 228
 						} else { \
227
-							syslog(LOG2SYSLOG_LEVEL(level) | \
228
-								   (((facility) != DEFAULT_FACILITY) ? \
229
-									(facility) : \
230
-								    get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \
231
-									"%s: %s" fmt, \
232
-									(lname)?(lname):LOG_LEVEL2NAME(level),\
233
-									(prefix), __VA_ARGS__); \
229
+							fprintf(stderr, "%2d(%d) %s: %s" fmt, \
230
+								process_no, my_pid(), \
231
+								(lname)?(lname):LOG_LEVEL2NAME(__llevel), \
232
+								(prefix) , __VA_ARGS__);\
234 233
 						} \
234
+						if (unlikely(log_color)) dprint_color_reset(); \
235 235
 					} else { \
236
-						if (log_stderr) { \
237
-							if (unlikely(log_color)) dprint_color(level); \
238
-							fprintf(stderr, "%2d(%d) %s" fmt, \
239
-									process_no, my_pid(), \
240
-									(prefix),  __VA_ARGS__); \
241
-							if (unlikely(log_color)) dprint_color_reset(); \
236
+						if(unlikely(log_prefix_val)) { \
237
+							_km_log_func(LOG2SYSLOG_LEVEL(__llevel) |\
238
+							    (((facility) != DEFAULT_FACILITY) ? \
239
+								(facility) : \
240
+								get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \
241
+								"%.*s%s: %s" fmt,\
242
+								log_prefix_val->len, log_prefix_val->s, \
243
+								(lname)?(lname):LOG_LEVEL2NAME(__llevel),\
244
+								(prefix) , __VA_ARGS__); \
242 245
 						} else { \
243
-							if ((level)<L_ALERT) \
244
-								syslog(LOG2SYSLOG_LEVEL(L_ALERT) | \
245
-									   (((facility) != DEFAULT_FACILITY) ? \
246
-										(facility) : \
247
-								        get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \
248
-									   "%s" fmt, (prefix), __VA_ARGS__); \
249
-							else \
250
-								syslog(LOG2SYSLOG_LEVEL(L_DBG) | \
251
-									   (((facility) != DEFAULT_FACILITY) ? \
252
-										(facility) : \
253
-								        get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \
254
-									   "%s" fmt, (prefix), __VA_ARGS__); \
246
+							_km_log_func(LOG2SYSLOG_LEVEL(__llevel) |\
247
+							    (((facility) != DEFAULT_FACILITY) ? \
248
+								(facility) : \
249
+								get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \
250
+								"%s: %s" fmt,\
251
+								(lname)?(lname):LOG_LEVEL2NAME(__llevel),\
252
+								(prefix) , __VA_ARGS__); \
255 253
 						} \
256 254
 					} \
257 255
 					DPRINT_CRIT_EXIT; \
258 256
 				} \
259 257
 			} while(0)
260 258
 
261
-#		define LOG_(facility, level, lname, prefix, fmt, ...) \
262
-	LOG__(facility, level, NULL, prefix, fmt, __VA_ARGS__)
259
+#		define LOG_(facility, level, ...) \
260
+	LOG__(facility, level, NULL, __VA_ARGS__, NULL)
263 261
 
264 262
 #		ifdef LOG_FUNC_NAME
265
-#			define LOG(level, fmt, ...) \
263
+#			define LOG(level, ...) \
264
+				_LOG(level, __VA_ARGS__, NULL)
265
+#			define _LOG(level, fmt, ...) \
266 266
 	LOG_(DEFAULT_FACILITY, (level), LOC_INFO, "%s(): " fmt,\
267 267
 				_FUNC_NAME_, __VA_ARGS__)
268 268
 
269
-#			define LOG_FC(facility, level, fmt, ...) \
270
-	LOG_((facility), (level), LOC_INFO, "%s(): " fmt,\
271
-				_FUNC_NAME_, __VA_ARGS__)
269
+#			define LOG_FC(facility, level, ...) \
270
+				_LOG_FC(facility, level, __VA_ARGS__, NULL)
271
+#			define _LOG_FC(facility, level, fmt, ...) \
272
+	LOG_((facility), (level), LOC_INFO, "%s(): " fmt , _FUNC_NAME_, __VA_ARGS__)
272 273
 
273
-#			define LOG_LN(level, lname, fmt, ...) \
274
+#			define LOG_LN(level, lname, ...) \
275
+				_LOG_LN(level, lname, __VA_ARGS__, NULL)
276
+#			define _LOG_LN(level, lname, fmt, ...) \
274 277
 	LOG__(DEFAULT_FACILITY, (level), (lname), LOC_INFO, "%s(): " fmt,\
275 278
 				_FUNC_NAME_, __VA_ARGS__)
276 279
 
277 280
 #		else /* LOG_FUNC_NAME */
278
-
279
-#			define LOG(level, fmt, ...) \
280
-	LOG_(DEFAULT_FACILITY, (level), LOC_INFO, fmt, __VA_ARGS__)
281
-
282
-#			define LOG_FC(facility, level, fmt, ...) \
283
-	LOG_((facility), (level), LOC_INFO, fmt, __VA_ARGS__)
284
-
285
-#			define LOG_LN(level, lname, fmt, ...) \
286
-	LOG_(DEFAULT_FACILITY, (level), (lname), LOC_INFO, fmt, __VA_ARGS__)
281
+#			define LOG(level, ...) \
282
+	LOG_(DEFAULT_FACILITY, (level), LOC_INFO, __VA_ARGS__, NULL)
283
+#			define LOG_FC(facility, level, ...) \
284
+	LOG_((facility), (level), LOC_INFO, __VA_ARGS__, NULL)
285
+#			define LOG_LN(level, lname, ...) \
286
+	LOG__(DEFAULT_FACILITY, (level), (lname), LOC_INFO, __VA_ARGS__, NULL)
287 287
 
288 288
 #		endif /* LOG_FUNC_NAME */
289 289
 
... ...
@@ -380,7 +380,7 @@ void log_prefix_init(void);
380 380
 #		define DBG(...)
381 381
 #	else
382 382
 #		define DBG(...)    LOG(L_DBG, __VA_ARGS__)
383
-#	endif		
383
+#	endif
384 384
 /*@ } */
385 385
 
386 386
 /* obsolete, do not use */