flog

来源:互联网 发布:mac天翼飞young连不上 编辑:程序博客网 时间:2024/06/05 22:42
#include "stdafx.h"#include "stdio.h"void flog(const char* format,...){char lpPath[100]={0};  sprintf(lpPath,"log%d.txt",GetCurrentThreadId());char name[32];FILE *fd = fopen(lpPath,"a+b");va_list va;#define MAX_LOG_BUFF 1024char buf[MAX_LOG_BUFF];va_start(va,format);_vsnprintf(buf,MAX_LOG_BUFF,format,va);va_end(va);SYSTEMTIME  stime;GetSystemTime(&stime);fprintf(fd,"[%.2d:%.2d:%.2d][%d]%s\r\n",stime.wHour+8,stime.wMinute,stime.wSecond,GetCurrentThreadId(),buf);fclose(fd);}void fdata( unsigned char* data,int len){char lpPath[100]={0};  sprintf(lpPath,"log%d.txt",GetCurrentThreadId());FILE *fd = fopen(lpPath,"a+b");char* bbuf = new char [len*2+2];memset(bbuf,0,len*2+2);int  i;for(i=0;i<len;i++){char sbuf[10];sprintf(sbuf,"%.2x",data[i]);strcat(bbuf,sbuf);} fprintf(fd,"%s\r\n",bbuf);fclose(fd);delete bbuf;}

0 0
原创粉丝点击