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
|
#include <lib/base/eerror.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string>
// #include <lib/gui/emessage.h>
int infatal=0;
Signal2<void, int, const std::string&> logOutput;
int logOutputConsole=1;
void eFatal(const char* fmt, ...)
{
char buf[1024];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, 1024, fmt, ap);
va_end(ap);
logOutput(lvlFatal, buf);
fprintf(stderr, "%s\n",buf );
#if 0
if (!infatal)
{
infatal=1;
eMessageBox msg(buf, "FATAL ERROR", eMessageBox::iconError|eMessageBox::btOK);
msg.show();
msg.exec();
}
#endif
_exit(0);
}
#ifdef DEBUG
void eDebug(const char* fmt, ...)
{
char buf[1024];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, 1024, fmt, ap);
va_end(ap);
logOutput(lvlDebug, std::string(buf) + "\n");
if (logOutputConsole)
fprintf(stderr, "%s\n", buf);
}
void eDebugNoNewLine(const char* fmt, ...)
{
char buf[1024];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, 1024, fmt, ap);
va_end(ap);
logOutput(lvlDebug, buf);
if (logOutputConsole)
fprintf(stderr, "%s", buf);
}
void eWarning(const char* fmt, ...)
{
char buf[1024];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, 1024, fmt, ap);
va_end(ap);
logOutput(lvlWarning, std::string(buf) + "\n");
if (logOutputConsole)
fprintf(stderr, "%s\n", buf);
}
#endif // DEBUG
|