24 #include <sigc++/sigc++.h> 27 #ifdef TEST_DEBUGSTREAM 38 static const type ANY = type(INFO | WARN | CRIT);
39 static Debug::type
value(std::string
const& val)
41 if (val ==
"NONE")
return Debug::NONE;
43 if (val ==
"INFO")
return Debug::INFO;
45 if (val ==
"WARN")
return Debug::WARN;
47 if (val ==
"CRIT")
return Debug::CRIT;
99 DebugStream(
char const* f, Debug::type t = Debug::NONE,
bool truncate =
false );
104 typedef sigc::signal<void, const std::string&> StreamEvent_Signal;
105 StreamEvent_Signal signal_stream_event();
110 dt = Debug::type(t & Debug::ANY);
122 dt = Debug::type(
dt | t);
128 dt = Debug::type(
dt & ~t);
132 virtual void logFile(
const std::string& f,
bool truncate =
false );
134 inline std::string getLogFile() const noexcept
140 inline void setLogFile(
const std::string& n ) noexcept
146 inline bool isOnLogFile() const noexcept
148 return isWriteLogFile;
152 inline void onLogFile(
bool truncate =
false )
158 inline void offLogFile() noexcept
164 void enableOnScreen();
167 void disableOnScreen();
170 inline bool debugging(Debug::type t = Debug::ANY)
const noexcept
179 std::ostream&
debug(Debug::type t = Debug::ANY) noexcept;
197 inline std::ostream&
to_end(Debug::type t) noexcept
205 std::ostream&
operator()(Debug::type t) noexcept;
207 inline void showDateTime(
bool s) noexcept
212 inline void showMilliseconds(
bool s ) noexcept
217 inline void showMicroseconds(
bool s ) noexcept
222 inline void showLogType(
bool s) noexcept
227 inline std::ostream& log(Debug::type l) noexcept
237 #define DMANIP(FNAME,LEVEL) \ 238 inline std::ostream& FNAME( bool showdatetime=true ) noexcept \ 241 return operator[](Debug::LEVEL); \ 242 return operator()(Debug::LEVEL); \ 245 inline bool is_##FNAME() const noexcept\ 246 { return debugging(Debug::LEVEL); } 248 DMANIP(level1, LEVEL1)
249 DMANIP(level2, LEVEL2)
250 DMANIP(level3, LEVEL3)
251 DMANIP(level4, LEVEL4)
252 DMANIP(level5, LEVEL5)
253 DMANIP(level6, LEVEL6)
254 DMANIP(level7, LEVEL7)
255 DMANIP(level8, LEVEL8)
256 DMANIP(level9, LEVEL9)
260 DMANIP(repository, REPOSITORY)
261 DMANIP(system, SYSTEM)
262 DMANIP(exception, EXCEPTION)
266 std::ostream& printDate(Debug::type t,
char brk =
'/') noexcept;
267 std::ostream& printTime(
Debug::type t,
char brk = ':') noexcept;
268 std::ostream& printDateTime(
Debug::type t) noexcept;
270 std::ostream& pos(
int x,
int y) noexcept;
274 inline
void setLogName( const std::
string& n ) noexcept
279 inline std::string getLogName() const noexcept
285 void sbuf_overflow(
const std::string& s ) noexcept;
289 Debug::type
dt = { Debug::NONE };
296 bool show_datetime = {
true };
297 bool show_logtype = {
true };
298 bool show_msec = {
false };
299 bool show_usec = {
false };
300 std::string fname = {
"" };
302 StreamEvent_Signal s_stream;
303 std::string logname = {
"" };
305 bool isWriteLogFile = {
false };
306 bool onScreen = {
true };
Definition: DebugStream.h:91
Debug::type dt
The current debug level.
Definition: DebugStream.h:289
bool debugging(Debug::type t=Debug::ANY) const noexcept
Returns true if t is part of the current debug level.
Definition: DebugStream.h:170
std::ostream & operator[](Debug::type t) noexcept
Definition: DebugStream.h:189
std::ostream nullstream
The no-op stream.
Definition: DebugStream.h:291
void addLevel(Debug::type t) noexcept
Adds t to the current debug level.
Definition: DebugStream.h:120
void delLevel(Debug::type t) noexcept
Deletes t from the current debug level.
Definition: DebugStream.h:126
std::ostream & to_end(Debug::type t) noexcept
Definition: DebugStream.h:197
virtual void logFile(const std::string &f, bool truncate=false)
Sets the debugstreams' logfile to f.
Definition: DebugStream.cc:115
static Debug::type value(std::string const &val)
Definition: Debug.cc:67
std::ostream & debug(Debug::type t=Debug::ANY) noexcept
Definition: DebugStream.cc:172
std::ostream & operator()(Debug::type t) noexcept
Definition: DebugStream.cc:190
void level(Debug::type t) noexcept
Sets the debug level to t.
Definition: DebugStream.h:108
So that public parts of DebugStream does not need to know about filebuf.
Definition: DebugExtBuf.h:357
Debug::type level() const noexcept
Returns the current debug level.
Definition: DebugStream.h:114
DebugStream(Debug::type t=Debug::NONE)
Constructor, sets the debug level to t.
Definition: DebugStream.cc:47