summaryrefslogtreecommitdiff
path: root/windows/keybuddy2/src/logger.cpp
blob: 936723b7d69064b846fd4da6fb3e8c25604c870a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

#include "includes.h"

FILE* plogfile;
char linebuffer[2048]={0};

void startLog(const char* fname){
	plogfile=fopen(fname, "wb");
}

void logg(const char* txt){
	fprintf(plogfile,"%s",txt);
	sprintf(linebuffer,"%s%s",linebuffer,txt);
}

void logg(WString txt){
	String utf8=ToUtf8(txt);
	fprintf(plogfile,"%s",utf8.Begin());
	sprintf(linebuffer,"%s%s",linebuffer,utf8.Begin());
}

void logg(bool b){
	if(b){
		fprintf(plogfile,"true");
		strcat(linebuffer,"true");
	}
	else{
		fprintf(plogfile,"false");
		strcat(linebuffer,"false");	
	}
}

void logg(int num){
	fprintf(plogfile,"%d",num);
	sprintf(linebuffer,"%s%d",linebuffer,num);	
}

void logg(double num){
	fprintf(plogfile,"%f",num);
	sprintf(linebuffer,"%s%f",linebuffer,num);		
}

void logg(wchar uni){
	fprintf(plogfile,"&#%d;",uni);
	sprintf(linebuffer,"%s[U+%d]",linebuffer,uni);
}

void loggnl(){
	fprintf(plogfile,"<br>\n");
	sprintf(linebuffer,"%s\n",linebuffer);
	KeyBuddy2::pdisplay->Insert(0,linebuffer);
	memset(linebuffer,0,sizeof(linebuffer));
}

void endLog(){
	fclose(plogfile);
}