ZNC  trunk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ZNCDebug.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004-2014 ZNC, see the NOTICE file for details.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ZNCDEBUG_H
18 #define ZNCDEBUG_H
19 
20 #include <znc/zncconfig.h>
21 #include <znc/ZNCString.h>
22 #include <sstream>
23 
35 #define DEBUG(f) do { \
36  if (CDebug::Debug()) { \
37  CDebugStream sDebug;\
38  sDebug << f;\
39  } \
40 } while (0)
41 
42 class CDebug {
43 public:
44  static void SetStdoutIsTTY(bool b) { stdoutIsTTY = b; }
45  static bool StdoutIsTTY() { return stdoutIsTTY; }
46  static void SetDebug(bool b) { debug = b; }
47  static bool Debug() { return debug; }
48 
49 protected:
50  static bool stdoutIsTTY;
51  static bool debug;
52 };
53 
54 class CDebugStream : public std::ostringstream {
55 public:
56  ~CDebugStream();
57 };
58 
59 #endif // !ZNCDEBUG_H
static void SetDebug(bool b)
Definition: ZNCDebug.h:46
Definition: ZNCDebug.h:54
static bool debug
Definition: ZNCDebug.h:51
Definition: ZNCDebug.h:42
static bool Debug()
Definition: ZNCDebug.h:47
static bool StdoutIsTTY()
Definition: ZNCDebug.h:45
static bool stdoutIsTTY
Definition: ZNCDebug.h:50
static void SetStdoutIsTTY(bool b)
Definition: ZNCDebug.h:44