-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathZNCDebug.h
47 lines (40 loc) · 1.11 KB
/
ZNCDebug.h
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
/*
* Copyright (C) 2004-2011 See the AUTHORS file for details.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*/
#ifndef ZNCDEBUG_H
#define ZNCDEBUG_H
#include "zncconfig.h"
#include <iostream>
using std::cout;
using std::endl;
/** Output a debug info if debugging is enabled.
* If ZNC was compiled with <code>--enable-debug</code> or was started with
* <code>--debug</code>, the given argument will be sent to stdout.
*
* You can use all the features of C++ streams:
* @code
* DEBUG("I had " << errors << " errors");
* @endcode
*
* @param f The expression you want to display.
*/
#define DEBUG(f) do { \
if (CDebug::Debug()) { \
cout << f << endl; \
} \
} while (0)
class CDebug {
public:
static void SetStdoutIsTTY(bool b) { stdoutIsTTY = b; }
static bool StdoutIsTTY() { return stdoutIsTTY; }
static void SetDebug(bool b) { debug = b; }
static bool Debug() { return debug; }
protected:
static bool stdoutIsTTY;
static bool debug;
};
#endif // !ZNCDEBUG_H