1、添加log
printf("\033[1;43m %s,%s,%d\033[0m\n",__FILE__,__FUNCTION__,__LINE__);
FILE:文件名
FUNCTION:函数名
LINE:代码所在文件行数
static void console_log(const char *format, ...) {
static FILE *fpConsole; if (fpConsole == NULL) {
fpConsole = fopen("/dev/console", "w");
} if (fpConsole != NULL) {
char aMsg[];
va_list va;
va_start(va, format);
int nRet;
if (((nRet = vsnprintf(aMsg, sizeof(aMsg), format, va)) < ) ||
(nRet >= (int)sizeof(aMsg))) {
fprintf(fpConsole, "%s: nRet=%d, sizeof(aMsg)=%d\n", __FUNCTION__, nRet,
sizeof(aMsg));
}
va_end(va);
fprintf(fpConsole, "%s\n", aMsg);
}
}