标签:back ons bsp span har case buffer event libevent
void log_callback(int severity, const char *msg) { char szBuffer[512]; FILE *pFd = fopen("./log.txt", "ab+"); if (pFd == NULL) return; const char *severity_str; switch (severity) { case EVENT_LOG_DEBUG: severity_str = "debug"; break; case EVENT_LOG_MSG: severity_str = "msg"; break; case EVENT_LOG_WARN: severity_str = "warn"; break; case EVENT_LOG_ERR: severity_str = "err"; break; default: severity_str = "???"; break; } snprintf(szBuffer, sizeof(szBuffer), "[%s]:%s", severity_str, msg); (void)fwrite(szBuffer, 1, strlen(szBuffer), pFd); fclose(pFd); } int main() { //替换记录日志的默认函数 event_set_log_callback(log_callback); }
标签:back ons bsp span har case buffer event libevent
原文地址:https://www.cnblogs.com/osbreak/p/10269691.html