static void writeMsgToFile(FILE* pFile, const char* fmt, ...)
{
char buff[1024];
va_list args;
va_start(args, fmt);
vsprintf(buff, fmt, args);
va_end(args);
time_t current = time(0);
char* pctime = ctime(¤t);
char str[2048];
char strTime[128];
int length = strlen(pctime) - 1;
strncpy(strTime, pctime, length);
strTime[length] = '\0';
sprintf(str, "%s-%s\n", strTime, buff);
if (pFile) {
fwrite(str, 1, strlen(str), pFile);
fflush(pFile);
} else {
printf("str is %s", str);
}
}