MTK HTTP 协议之日志写入

将log日志写入文件

 

nw_log.c

 

#include "kal_non_specific_general_types.h"
#include "stack_config.h"
#include "kal_trace.h"
#include "DateTimeGprot.h"

static char nw_log_buf[4 * 1024];
#define NW_LOG_FILE_NAME = L"E:\\nw_log.txt";

void nw_vlog(char* buf)
{
#ifndef WIN32
   	kal_prompt_trace(MOD_WAP, "%s",  buf);
#else
	kal_printf("%s", buf);
#endif

#ifdef NW_LOG_ON
	{
		signed int file_handle;


		file_handle = nw_fs_open(NW_LOG_FILE_NAME, "a+");

		if (file_handle > 0)
		{
			nw_fs_write(file_handle, buf, strlen(buf));
			nw_fs_close(file_handle);
		}
		
	}
#endif
}
void nw_log(const char* fmt, ...)
{
	va_list arglist;
	MYTIME time;
	char* p = nw_log_buf;
	int l=0;
	
	va_start(arglist, fmt);
#if ! defined(WIN32) || defined(NW_LOG_TO_FILE)
	DTGetRTCTime(&time);
	l = sprintf(p, "[%02d-%02d %02d:%02d:%02d] ", time.nMonth, time.nDay, time.nHour, time.nMin, time.nSec);
#endif
	p += l;
	l = vsprintf(p, fmt, arglist);
	p += l;	
	*p ++ = 0x0d;
	*p ++ = 0x0a;
	*p ++ = 0x00;
	va_end(arglist);

	nw_vlog(nw_log_buf);
}


 

你可能感兴趣的:(list,File,WAP,MTK)