30 #ifndef _CL_LOG_UTIL_API_H_
31 #define _CL_LOG_UTIL_API_H_
44 #define CL_LOG_MAX_MSG_LEN 1024
45 #define CL_LOG_MAX_NUM_MSGS 992
61 clLogUtilLibFinalize(ClBoolT logLibInit);
66 #define CL_LOG_AREA_UNSPECIFIED "---"
71 #define CL_LOG_CONTEXT_UNSPECIFIED "---"
76 #define CL_LOG_DEFAULT_SYS_SERVICE_ID 0x01
87 #define clLog(severity, area, context, ...) \
90 const ClCharT *pArea = CL_LOG_AREA_UNSPECIFIED; \
91 const ClCharT *pContext = CL_LOG_CONTEXT_UNSPECIFIED; \
96 if( NULL != context ) \
100 clLogMsgWrite(CL_LOG_HANDLE_SYS, (ClLogSeverityT)severity, \
101 CL_LOG_DEFAULT_SYS_SERVICE_ID, \
102 pArea, pContext, __FILE__, __LINE__, \
106 #define clLogDeferred(severity, area, context, ...) \
109 const ClCharT *pArea = CL_LOG_AREA_UNSPECIFIED; \
110 const ClCharT *pContext = CL_LOG_CONTEXT_UNSPECIFIED; \
115 if( NULL != context ) \
117 pContext = context; \
119 clLogMsgWriteDeferred(CL_LOG_HANDLE_SYS, (ClLogSeverityT)severity, \
120 CL_LOG_DEFAULT_SYS_SERVICE_ID, \
121 pArea, pContext, __FILE__, __LINE__, \
125 #define clLogConsole(severity, area, context, ...) \
128 const ClCharT *pArea = CL_LOG_AREA_UNSPECIFIED; \
129 const ClCharT *pContext = CL_LOG_CONTEXT_UNSPECIFIED; \
134 if( NULL != context ) \
136 pContext = context; \
138 clLogMsgWriteConsole(CL_LOG_HANDLE_SYS, (ClLogSeverityT)severity, \
139 CL_LOG_DEFAULT_SYS_SERVICE_ID, \
140 pArea, pContext, __FILE__, __LINE__, \
179 #define clAppLog(streamHandle, severity, serviceId, area, context, ...) \
182 const ClCharT *pArea = CL_LOG_AREA_UNSPECIFIED; \
183 const ClCharT *pContext = CL_LOG_AREA_UNSPECIFIED; \
188 if( NULL != context ) \
190 pContext = context; \
192 clLogMsgWrite(streamHandle, severity, serviceId, pArea, pContext, \
193 __FILE__, __LINE__, __VA_ARGS__); \
206 extern void parseMultiline(ClCharT **ppMsg,
const ClCharT *pFmt, ...) CL_PRINTF_FORMAT(2, 3);
208 #define clLogMultiline(severity, area, context, ...) \
210 ClCharT *msg = NULL; \
211 ClCharT str[CL_LOG_SLINE_MSG_LEN+10] = {0}; \
212 ClCharT *pTemp = NULL; \
213 ClCharT *pStr = NULL; \
214 ClUint32T length = 0; \
215 parseMultiline(&msg, __VA_ARGS__); \
220 pTemp = strchr(pTemp, '\n'); \
221 if( NULL == pTemp ) { \
223 snprintf(str, CL_LOG_SLINE_MSG_LEN+3, "%s%s", \
224 ((pStr==msg) ? "" : "- "), pStr); \
225 clLog(severity, area, context, str); \
229 length = pTemp - pStr; \
232 snprintf(str, CL_LOG_SLINE_MSG_LEN+3,"%s%.*s", \
233 ((pStr==msg) ? "" : "- "), length, pStr); \
234 clLog(severity, area, context, str); \
236 pStr += (pTemp - pStr); \
247 #define clLogEmergency(area, context, ...) \
248 clLog(CL_LOG_SEV_EMERGENCY, area, context, __VA_ARGS__)
250 #define clLogConsoleEmergency(area, context, ...) \
251 clLogConsole(CL_LOG_SEV_EMERGENCY, area, context, __VA_ARGS__)
253 #define clLogAlert(area, context, ...) \
254 clLog(CL_LOG_SEV_ALERT, area, context, __VA_ARGS__)
256 #define clLogConsoleAlert(area, context, ...) \
257 clLogConsole(CL_LOG_SEV_ALERT, area, context, __VA_ARGS__)
259 #define clLogCritical(area, context, ...) \
260 clLog(CL_LOG_SEV_CRITICAL, area, context, __VA_ARGS__)
262 #define clLogConsoleCritical(area, context, ...) \
263 clLogConsole(CL_LOG_SEV_CRITICAL, area, context, __VA_ARGS__)
265 #define clLogError(area, context, ...) \
266 clLog(CL_LOG_SEV_ERROR, area, context, __VA_ARGS__)
268 #define clLogConsoleError(area, context, ...) \
269 clLogConsole(CL_LOG_SEV_ERROR, area, context, __VA_ARGS__)
271 #define clLogWarning(area, context, ...) \
272 clLog(CL_LOG_SEV_WARNING, area, context, __VA_ARGS__)
274 #define clLogConsoleWarning(area, context, ...) \
275 clLogConsole(CL_LOG_SEV_WARNING, area, context, __VA_ARGS__)
277 #define clLogNotice(area, context, ...) \
278 clLog(CL_LOG_SEV_NOTICE, area, context, __VA_ARGS__)
280 #define clLogConsoleNotice(area, context, ...) \
281 clLogConsole(CL_LOG_SEV_NOTICE, area, context, __VA_ARGS__)
283 #define clLogInfo(area, context, ...) \
284 clLog(CL_LOG_SEV_INFO, area, context, __VA_ARGS__)
286 #define clLogConsoleInfo(area, context, ...) \
287 clLogConsole(CL_LOG_SEV_INFO, area, context, __VA_ARGS__)
289 #define clLogDebug(area, context, ...) \
290 clLog(CL_LOG_SEV_DEBUG, area, context, __VA_ARGS__)
292 #define clLogConsoleDebug(area, context, ...) \
293 clLogConsole(CL_LOG_SEV_DEBUG, area, context, __VA_ARGS__)
295 #define clLogTrace(area, context, ...) \
296 clLog(CL_LOG_SEV_TRACE, area, context, __VA_ARGS__)
298 #define clLogConsoleTrace(area, context, ...) \
299 clLogConsole(CL_LOG_SEV_TRACE, area, context, __VA_ARGS__)