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();
108 void level(Debug::type t) noexcept
110 dt = Debug::type(t & Debug::ANY);
114 Debug::type level() const noexcept
120 void addLevel(Debug::type t) noexcept
122 dt = Debug::type(dt | t);
126 void delLevel(Debug::type t) noexcept
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;
183 std::ostream& operator[](
Debug::type t) 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
299 std::ios::fmtflags f;
304 void sbuf_overflow(
const std::string& s ) noexcept;
308 Debug::type dt = { Debug::NONE };
315 bool show_datetime = {
true };
316 bool show_logtype = {
true };
317 bool show_msec = {
false };
318 bool show_usec = {
false };
319 std::string fname = {
"" };
321 StreamEvent_Signal s_stream;
322 std::string logname = {
"" };
324 bool isWriteLogFile = {
false };