xoreos  0.0.5
debug.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 // Inspired by ScummVM's debug channels
22 
27 #include <cstdarg>
28 #include <cstdio>
29 #include <cstdlib>
30 
31 #include "src/common/debug.h"
32 #include "src/common/debugman.h"
33 
34 void debugC(Common::DebugChannel channel, uint32 level, const char *s, ...) {
35  if (!DebugMan.isEnabled(channel, level))
36  return;
37 
38  char buf[STRINGBUFLEN];
39  va_list va;
40 
41  va_start(va, s);
42  vsnprintf(buf, STRINGBUFLEN, s, va);
43  va_end(va);
44 
45 #ifndef DISABLE_TEXT_CONSOLE
46  std::fputs(buf, stderr);
47  std::fputs("\n", stderr);
48 #endif
49 
50  DebugMan.logString(buf);
51  DebugMan.logString("\n");
52 }
53 
54 void debugCN(Common::DebugChannel channel, uint32 level, const char *s, ...) {
55  if (!DebugMan.isEnabled(channel, level))
56  return;
57 
58  char buf[STRINGBUFLEN];
59  va_list va;
60 
61  va_start(va, s);
62  vsnprintf(buf, STRINGBUFLEN, s, va);
63  va_end(va);
64 
65 #ifndef DISABLE_TEXT_CONSOLE
66  std::fputs(buf, stderr);
67 #endif
68 
69  DebugMan.logString(buf);
70 }
void debugC(Common::DebugChannel channel, uint32 level, const char *s,...)
Definition: debug.cpp:34
Utility functions for debug output.
The debug manager, managing debug channels.
void debugCN(Common::DebugChannel channel, uint32 level, const char *s,...)
Definition: debug.cpp:54
#define DebugMan
Shortcut for accessing the debug manager.
Definition: debugman.h:195
DebugChannel
All debug channels.
Definition: debugman.h:41
#define STRINGBUFLEN
Definition: system.h:415
uint32_t uint32
Definition: types.h:204