20#include <sigc++/sigc++.h>
65 explicit DebugStream(Debug::type t = Debug::NONE, Debug::verbosity v = 0);
69 DebugStream(
char const* f, Debug::type t = Debug::NONE,
bool truncate =
false );
74 typedef sigc::signal<void, const std::string&> StreamEvent_Signal;
75 StreamEvent_Signal signal_stream_event();
78 void level(Debug::type t)
noexcept
80 dt = Debug::type(t & Debug::ANY);
84 Debug::type
level() const noexcept
92 dt = Debug::type(
dt | t);
98 dt = Debug::type(
dt & ~t);
102 virtual void logFile(
const std::string& f,
bool truncate =
false );
104 inline std::string getLogFile() const noexcept
110 inline void setLogFile(
const std::string& n )
noexcept
116 inline bool isOnLogFile() const noexcept
118 return isWriteLogFile;
122 inline void onLogFile(
bool truncate =
false )
128 inline void offLogFile() noexcept
134 void enableOnScreen();
137 void disableOnScreen();
140 inline bool debugging(Debug::type t = Debug::ANY)
const noexcept
149 std::ostream&
debug(Debug::type t = Debug::ANY)
noexcept;
163 inline std::ostream&
to_end(Debug::type t)
noexcept
171 std::ostream&
operator()(Debug::type t)
noexcept;
173 inline void showDateTime(
bool s)
noexcept
179 inline void showLocalTime(
bool s )
noexcept
184 inline void showMilliseconds(
bool s )
noexcept
189 inline void showMicroseconds(
bool s )
noexcept
194 inline void showLogType(
bool s)
noexcept
199 inline void showLabels(
bool s)
noexcept
204 inline void hideLabelKey(
bool s)
noexcept
209 inline std::ostream& log(Debug::type l)
noexcept
214 void verbose(Debug::verbosity v)
noexcept
229 typedef std::pair<std::string, std::string> Label;
231 void addLabel(
const std::string& key,
const std::string& value )
noexcept;
232 void delLabel(
const std::string& key )
noexcept;
233 void cleanupLabels() noexcept;
234 std::vector<Label> getLabels() noexcept;
242#define DMANIP(FNAME,LEVEL) \
243 inline std::ostream& FNAME( bool showdatetime=true ) noexcept \
246 return operator[](Debug::LEVEL); \
247 return operator()(Debug::LEVEL); \
250 inline bool is_##FNAME() const noexcept\
251 { return debugging(Debug::LEVEL); }
253 DMANIP(level1, LEVEL1)
254 DMANIP(level2, LEVEL2)
255 DMANIP(level3, LEVEL3)
256 DMANIP(level4, LEVEL4)
257 DMANIP(level5, LEVEL5)
258 DMANIP(level6, LEVEL6)
259 DMANIP(level7, LEVEL7)
260 DMANIP(level8, LEVEL8)
261 DMANIP(level9, LEVEL9)
265 DMANIP(repository, REPOSITORY)
266 DMANIP(system, SYSTEM)
267 DMANIP(exception, EXCEPTION)
271 std::ostream& printDate(Debug::type t,
char brk =
'/') noexcept;
272 std::ostream& printTime(
Debug::type t,
char brk = ':') noexcept;
273 std::ostream& printDateTime(
Debug::type t) noexcept;
275 std::ostream& pos(
int x,
int y) noexcept;
279 inline
void setLogName( const
std::
string& n ) noexcept
284 inline std::string getLogName() const noexcept
290 void sbuf_overflow(
const std::string& s )
noexcept;
294 Debug::type
dt = { Debug::NONE };
301 bool show_datetime = {
true };
302 bool show_logtype = {
true };
303 bool show_msec = {
false };
304 bool show_usec = {
false };
305 bool show_localtime = {
false };
306 std::string fname = {
"" };
308 StreamEvent_Signal s_stream;
309 std::string logname = {
"" };
311 bool isWriteLogFile = {
false };
312 bool onScreen = {
true };
314 Debug::verbosity verb = { 0 };
315 Debug::verbosity vv = { 0 };
317 std::vector<Label> labels;
318 bool show_labels = {
true };
319 bool hide_label_key = {
false };
Definition DebugStream.h:62
DebugStream(Debug::type t=Debug::NONE, Debug::verbosity v=0)
Constructor, sets the debug level to t.
Definition DebugStream.cc:34
void level(Debug::type t) noexcept
Sets the debug level to t.
Definition DebugStream.h:78
std::ostream & debug(Debug::type t=Debug::ANY) noexcept
Definition DebugStream.cc:161
std::ostream & operator()(Debug::type t) noexcept
Definition DebugStream.cc:192
Debug::type level() const noexcept
Returns the current debug level.
Definition DebugStream.h:84
virtual void logFile(const std::string &f, bool truncate=false)
Sets the debugstreams' logfile to f.
Definition DebugStream.cc:104
std::ostream & operator[](Debug::type t) noexcept
Definition DebugStream.h:155
std::ostream nullstream
The no-op stream.
Definition DebugStream.h:296
bool debugging(Debug::type t=Debug::ANY) const noexcept
Returns true if t is part of the current debug level.
Definition DebugStream.h:140
std::ostream & to_end(Debug::type t) noexcept
Definition DebugStream.h:163
Debug::verbosity verbose() const noexcept
Returns the current verbose level.
Definition DebugStream.h:220
void delLevel(Debug::type t) noexcept
Deletes t from the current debug level.
Definition DebugStream.h:96
void addLevel(Debug::type t) noexcept
Adds t to the current debug level.
Definition DebugStream.h:90
Debug::type dt
The current debug level.
Definition DebugStream.h:294
So that public parts of DebugStream does not need to know about filebuf.
Definition DebugExtBuf.h:358