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 )
154 logFile(fname, truncate);
158 inline void offLogFile() noexcept
164 inline bool debugging(Debug::type t = Debug::ANY)
const noexcept
173 std::ostream& debug(Debug::type t = Debug::ANY) noexcept;
191 inline std::ostream&
to_end(Debug::type t) noexcept
193 return this->operator()(t);
199 std::ostream& operator()(Debug::type t) noexcept;
201 inline void showDateTime(
bool s) noexcept
206 inline void showMilliseconds(
bool s ) noexcept
211 inline void showMicroseconds(
bool s ) noexcept
216 inline void showLogType(
bool s) noexcept
221 inline std::ostream& log(Debug::type l) noexcept
223 return this->operator[](l);
231 #define DMANIP(FNAME,LEVEL) \ 232 inline std::ostream& FNAME( bool showdatetime=true ) noexcept \ 235 return operator[](Debug::LEVEL); \ 236 return operator()(Debug::LEVEL); \ 239 inline bool is_##FNAME() const noexcept\ 240 { return debugging(Debug::LEVEL); } 242 DMANIP(level1, LEVEL1)
243 DMANIP(level2, LEVEL2)
244 DMANIP(level3, LEVEL3)
245 DMANIP(level4, LEVEL4)
246 DMANIP(level5, LEVEL5)
247 DMANIP(level6, LEVEL6)
248 DMANIP(level7, LEVEL7)
249 DMANIP(level8, LEVEL8)
250 DMANIP(level9, LEVEL9)
254 DMANIP(repository, REPOSITORY)
255 DMANIP(system, SYSTEM)
256 DMANIP(exception, EXCEPTION)
260 std::ostream& printDate(Debug::type t,
char brk =
'/') noexcept;
261 std::ostream& printTime(Debug::type t,
char brk =
':') noexcept;
262 std::ostream& printDateTime(Debug::type t) noexcept;
264 std::ostream& pos(
int x,
int y) noexcept;
268 inline void setLogName(
const std::string& n ) noexcept
273 inline std::string getLogName()
const noexcept
279 void sbuf_overflow(
const std::string& s ) noexcept;
283 Debug::type dt = { Debug::NONE };
290 bool show_datetime = {
true };
291 bool show_logtype = {
true };
292 bool show_msec = {
false };
293 bool show_usec = {
false };
294 std::string fname = {
"" };
296 StreamEvent_Signal s_stream;
297 std::string logname = {
"" };
299 bool isWriteLogFile = {
false };
Definition: DebugStream.h:91
bool debugging(Debug::type t=Debug::ANY) const noexcept
Returns true if t is part of the current debug level.
Definition: DebugStream.h:164
std::ostream & operator[](Debug::type t) noexcept
Definition: DebugStream.h:183
std::ostream nullstream
The no-op stream.
Definition: DebugStream.h:285
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:191
static Debug::type value(std::string const &val)
Definition: Debug.cc:67
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