FILE *logFileHandle=NULL;


void log_add(const char *format,...)
{
	int o;
	char str[4096];
	va_list arg;
	
	if(!logFileHandle) return;
	
	va_start(arg,format);
	o=vsprintf(str,format,arg);
	va_end(arg);
	fwrite(str,strlen(str),1,logFileHandle);
	fflush(logFileHandle);
}


/*
inline void log_add_time(void)
{
	SYSTEMTIME time;
	
	GetLocalTime(&time);
	log_add("[%2.2i.%2.2i.%2.2i %2.2i:%2.2i]\n",time.wDay,time.wMonth,time.wYear,time.wHour,time.wMinute);
}
*/


inline void log_open(const char *filename)
{
	logFileHandle=fopen(filename,"wt");
	//log_add_time();
	//log_add(msgLogBegin);
}



inline void log_close(void)
{
	//log_add(msgLogEnd);
	//log_add_time();
	fclose(logFileHandle);
	logFileHandle=NULL;
}