aboutsummaryrefslogtreecommitdiffstats
path: root/src/frontend/swlog.cpp
blob: 15f26fb1d562401277fa38f8f90ad2cbe7842729 (plain) (blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//---------------------------------------------------------------------------

#include <stdarg.h>
#include <stdio.h>
#ifndef _MSC_VER
#include <iostream>
#endif
#if defined(_ICU_) && !defined(_ICUSWORD_)
#define _USTDIO_
#include <unicode/ustdio.h>
#include <unicode/ustream.h>
#endif
#include "swlog.h"
//---------------------------------------------------------------------------


SWLog *SWLog::systemlog = 0;


class __staticsystemlog {
public:
	__staticsystemlog() {
		SWLog::systemlog = new SWLog();
	}
	~__staticsystemlog() {
		delete SWLog::systemlog;
	}
} _staticsystemlog;


void SWLog::LogWarning(char *fmt, ...)
{
	#ifdef _USTDIO_
	UChar msg[2048];
	#else
	char msg[2048];
	#endif
	va_list argptr;

	if (logLevel >= 2) {
		va_start(argptr, fmt);
		#ifdef _USTDIO_
		u_vsprintf(msg, NULL, fmt, argptr);
		#else
		vsprintf(msg, fmt, argptr);
		#endif
		va_end(argptr);

#ifndef _MSC_VER
		std::cerr << msg;
		std::cerr << std::endl;
#endif
	}
}


void SWLog::LogError(char *fmt, ...)
{
	#ifdef _USTDIO_
	UChar msg[2048];
	#else
	char msg[2048];
	#endif
	va_list argptr;

	if (logLevel) {
		va_start(argptr, fmt);
		#ifdef _USTDIO_
		u_vsprintf(msg, NULL, fmt, argptr);
		#else
		vsprintf(msg, fmt, argptr);
		#endif
		va_end(argptr);

#ifndef _MSC_VER
		std::cerr << msg;
		std::cerr << std::endl;
#endif
	}
}


void SWLog::LogTimedInformation(char *fmt, ...)
{
	#ifdef _USTDIO_
	UChar msg[2048];
	#else
	char msg[2048];
	#endif
	va_list argptr;

	if (logLevel >= 4) {
		va_start(argptr, fmt);
		#ifdef _USTDIO_
		u_vsprintf(msg, NULL, fmt, argptr);
		#else
		vsprintf(msg, fmt, argptr);
		#endif
		va_end(argptr);

#ifndef _MSC_VER
		std::cout << msg;
		std::cout << std::endl;
#endif
	}
}


void SWLog::LogInformation(char *fmt, ...)
{
	#ifdef _USTDIO_
	UChar msg[2048];
	#else
	char msg[2048];
	#endif
	va_list argptr;

	if (logLevel >= 3) {
		va_start(argptr, fmt);
		#ifdef _USTDIO_
		u_vsprintf(msg, NULL, fmt, argptr);
		#else
		vsprintf(msg, fmt, argptr);
		#endif
		va_end(argptr);

#ifndef _MSC_VER
		std::cout << msg;
		std::cout << std::endl;
#endif
	}
}