ZNC  trunk
ZNCDebug.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004-2024 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) \
36  do { \
37  if (CDebug::Debug()) { \
38  CDebugStream sDebug; \
39  sDebug << f; \
40  } \
41  } while (0)
42 
43 class CDebug {
44  public:
45  static void SetStdoutIsTTY(bool b) { stdoutIsTTY = b; }
46  static bool StdoutIsTTY() { return stdoutIsTTY; }
47  static void SetDebug(bool b) { debug = b; }
48  static bool Debug() { return debug; }
49 
50  static CString Filter(const CString& sUnfilteredLine);
51 
52  protected:
53  static bool stdoutIsTTY;
54  static bool debug;
55 };
56 
57 class CDebugStream : public std::ostringstream {
58  public:
60 };
61 
62 #endif // !ZNCDEBUG_H
Definition: ZNCDebug.h:57
Definition: ZNCDebug.h:43
static bool debug
Definition: ZNCDebug.h:54
static bool stdoutIsTTY
Definition: ZNCDebug.h:53
static void SetStdoutIsTTY(bool b)
Definition: ZNCDebug.h:45
static bool Debug()
Definition: ZNCDebug.h:48
static CString Filter(const CString &sUnfilteredLine)
static bool StdoutIsTTY()
Definition: ZNCDebug.h:46
static void SetDebug(bool b)
Definition: ZNCDebug.h:47
String class that is used inside ZNC.
Definition: ZNCString.h:68