void log_it_ex(LogContext *pContext, const int priority, const char *format, ...) { bool bNeedSync; char text[LINE_MAX]; char *caption; int len; va_list ap; va_start(ap, format); len = vsnprintf(text, sizeof(text), format, ap); va_end(ap); if (len >= sizeof(text)) { len = sizeof(text) - 1; } switch(priority) { case LOG_DEBUG: bNeedSync = true; caption = "DEBUG"; break; case LOG_INFO: bNeedSync = true; caption = "INFO"; break; case LOG_NOTICE: bNeedSync = false; caption = "NOTICE"; break; case LOG_WARNING: bNeedSync = false; caption = "WARNING"; break; case LOG_ERR: bNeedSync = false; caption = "ERROR"; break; case LOG_CRIT: bNeedSync = true; caption = "CRIT"; break; case LOG_ALERT: bNeedSync = true; caption = "ALERT"; break; case LOG_EMERG: bNeedSync = true; caption = "EMERG"; break; default: bNeedSync = false; caption = "UNKOWN"; break; } log_it_ex2(pContext, caption, text, len, bNeedSync, true); }
void log_it_ex1(LogContext *pContext, const int priority, \ const char *text, const int text_len) { bool bNeedSync; char *caption; if (pContext->log_level < priority) { return; } switch (priority) { case LOG_DEBUG: bNeedSync = true; caption = "DEBUG"; break; case LOG_INFO: bNeedSync = true; caption = "INFO"; break; case LOG_NOTICE: bNeedSync = false; caption = "NOTICE"; break; case LOG_WARNING: bNeedSync = false; caption = "WARNING"; break; case LOG_ERR: bNeedSync = false; caption = "ERROR"; break; case LOG_CRIT: bNeedSync = true; caption = "CRIT"; break; case LOG_ALERT: bNeedSync = true; caption = "ALERT"; break; case LOG_EMERG: bNeedSync = true; caption = "EMERG"; break; default: bNeedSync = false; caption = "UNKOWN"; break; } log_it_ex2(pContext, caption, text, text_len, bNeedSync, true); }