- new GUI lib
[enigma2.git] / lib / base / eerror.cpp
1 #include <lib/base/eerror.h>
2 #include <stdarg.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6
7 #include <lib/base/estring.h>
8
9 // #include <lib/gui/emessage.h>
10
11 int infatal=0;
12
13 Signal2<void, int, const eString&> logOutput;
14 int logOutputConsole=1;
15
16 void eFatal(const char* fmt, ...)
17 {
18         char buf[1024];
19         va_list ap;
20         va_start(ap, fmt);
21         vsnprintf(buf, 1024, fmt, ap);
22         va_end(ap);
23         logOutput(lvlFatal, buf);
24         fprintf(stderr, "%s\n",buf );
25 #if 0
26         if (!infatal)
27         {
28                 infatal=1;
29                 eMessageBox msg(buf, "FATAL ERROR", eMessageBox::iconError|eMessageBox::btOK);
30                 msg.show();
31                 msg.exec();
32         }
33 #endif
34
35         _exit(0);
36 }
37
38 #ifdef DEBUG
39 void eDebug(const char* fmt, ...)
40 {
41         char buf[1024];
42         va_list ap;
43         va_start(ap, fmt);
44         vsnprintf(buf, 1024, fmt, ap);
45         va_end(ap);
46         logOutput(lvlDebug, eString(buf) + "\n");
47         if (logOutputConsole)
48                 fprintf(stderr, "%s\n", buf);
49 }
50
51 void eDebugNoNewLine(const char* fmt, ...)
52 {
53         char buf[1024];
54         va_list ap;
55         va_start(ap, fmt);
56         vsnprintf(buf, 1024, fmt, ap);
57         va_end(ap);
58         logOutput(lvlDebug, buf);
59         if (logOutputConsole)
60                 fprintf(stderr, "%s", buf);
61 }
62
63 void eWarning(const char* fmt, ...)
64 {
65         char buf[1024];
66         va_list ap;
67         va_start(ap, fmt);
68         vsnprintf(buf, 1024, fmt, ap);
69         va_end(ap);
70         logOutput(lvlWarning, eString(buf) + "\n");
71         if (logOutputConsole)
72                 fprintf(stderr, "%s\n", buf);
73 }
74 #endif // DEBUG