UniSet 2.32.1
Классы | Открытые типы | Открытые члены | Защищенные члены | Защищенные данные | Полный список членов класса
Класс DebugStream

#include <DebugStream.h>

Граф наследования:DebugStream:
Inheritance graph
[см. легенду]
Граф связей класса DebugStream:
Collaboration graph
[см. легенду]

Классы

struct  debugstream_internal
 So that public parts of DebugStream does not need to know about filebuf. Подробнее...
 

Открытые типы

typedef sigc::signal< void, const std::string & > StreamEvent_Signal
 
typedef std::pair< std::string, std::string > Label
 

Открытые члены

 DebugStream (Debug::type t=Debug::NONE, Debug::verbosity v=0)
 Constructor, sets the debug level to t.
 
 DebugStream (char const *f, Debug::type t=Debug::NONE, bool truncate=false)
 Constructor, sets the log file to f, and the debug level to t.
 
StreamEvent_Signal signal_stream_event ()
 
void level (Debug::type t) noexcept
 Sets the debug level to t.
 
Debug::type level () const noexcept
 Returns the current debug level.
 
void addLevel (Debug::type t) noexcept
 Adds t to the current debug level.
 
void delLevel (Debug::type t) noexcept
 Deletes t from the current debug level.
 
virtual void logFile (const std::string &f, bool truncate=false)
 Sets the debugstreams' logfile to f.
 
std::string getLogFile () const noexcept
 
void setLogFile (const std::string &n) noexcept
 
bool isOnLogFile () const noexcept
 
void onLogFile (bool truncate=false)
 
void offLogFile () noexcept
 
void enableOnScreen ()
 
void disableOnScreen ()
 
bool debugging (Debug::type t=Debug::ANY) const noexcept
 Returns true if t is part of the current debug level.
 
std::ostream & debug (Debug::type t=Debug::ANY) noexcept
 
std::ostream & operator[] (Debug::type t) noexcept
 
std::ostream & to_end (Debug::type t) noexcept
 
std::ostream & operator() (Debug::type t) noexcept
 
void showDateTime (bool s) noexcept
 
void showLocalTime (bool s) noexcept
 
void showMilliseconds (bool s) noexcept
 
void showMicroseconds (bool s) noexcept
 
void showLogType (bool s) noexcept
 
void showLabels (bool s) noexcept
 
void hideLabelKey (bool s) noexcept
 
std::ostream & log (Debug::type l) noexcept
 
void verbose (Debug::verbosity v) noexcept
 
Debug::verbosity verbose () const noexcept
 Returns the current verbose level.
 
DebugStreamV (Debug::verbosity v) noexcept
 
void addLabel (const std::string &key, const std::string &value) noexcept
 
void delLabel (const std::string &key) noexcept
 
void cleanupLabels () noexcept
 
std::vector< Label > getLabels () noexcept
 
std::ostream & printDate (Debug::type t, char brk='/') noexcept
 
std::ostream & printTime (Debug::type t, char brk=':') noexcept
 
std::ostream & printDateTime (Debug::type t) noexcept
 
std::ostream & pos (int x, int y) noexcept
 
const DebugStreamoperator= (const DebugStream &r)
 
void setLogName (const std::string &n) noexcept
 
std::string getLogName () const noexcept
 

Защищенные члены

void sbuf_overflow (const std::string &s) noexcept
 

Защищенные данные

Debug::type dt = { Debug::NONE }
 The current debug level.
 
std::ostream nullstream
 The no-op stream.
 
debugstream_internalinternal = { 0 }
 
bool show_datetime = { true }
 
bool show_logtype = { true }
 
bool show_msec = { false }
 
bool show_usec = { false }
 
bool show_localtime = { false }
 
std::string fname = { "" }
 
StreamEvent_Signal s_stream
 
std::string logname = { "" }
 
bool isWriteLogFile = { false }
 
bool onScreen = { true }
 
Debug::verbosity verb = { 0 }
 
Debug::verbosity vv = { 0 }
 
std::vector< Label > labels
 
bool show_labels = { true }
 
bool hide_label_key = { false }
 

Подробное описание

DebugStream is a ostream intended for debug output. It has also support for a logfile. Debug output is output to cerr and if the logfile is set, to the logfile.

Example of Usage: DebugStream debug; debug.level(Debug::INFO); debug.debug(Debug::WARN) << "WARN\n"; debug[Debug::INFO] << "INFO\n"; debug << "Always\n";

Will output: INFO Always

If you want to have debug output from time critical code you should use this construct: if (debug.is_info()) { debug << "...debug output...\n"; }

To give debug info even if no debug (NONE) is requested: debug << "... always output ...\n";

To give debug output regardless of what debug level is set (!NONE): debug.debug() << "...on debug output...\n"; debug[Debug::ANY] << "...on debug output...\n";

To give debug output when a specific debug level is set (INFO): debug.debug(Debug::INFO) << "...info...\n"; debug[Debug::INFO] << "...info...\n";

To give debug output when either on of debug levels is set (INFO or CRIT): debug.debug(Debug::type(Debug::INFO | Debug::CRIT)) << "...info/crit...\n"; debug[Debug::type(Debug::INFO | Debug::CRIT)] << "...info/crit...\n";

Конструктор(ы)

◆ DebugStream() [1/2]

DebugStream::DebugStream ( Debug::type t = Debug::NONE,
Debug::verbosity v = 0 )
explicit

Constructor, sets the debug level to t.

◆ DebugStream() [2/2]

DebugStream::DebugStream ( char const * f,
Debug::type t = Debug::NONE,
bool truncate = false )
explicit

Constructor, sets the log file to f, and the debug level to t.

Методы

◆ addLevel()

void DebugStream::addLevel ( Debug::type t)
inlinenoexcept

Adds t to the current debug level.

◆ debug()

std::ostream & DebugStream::debug ( Debug::type t = Debug::ANY)
noexcept

Returns the no-op stream if t is not part of the current debug level otherwise the real debug stream is used.

◆ debugging()

bool DebugStream::debugging ( Debug::type t = Debug::ANY) const
inlinenoexcept

Returns true if t is part of the current debug level.

◆ delLevel()

void DebugStream::delLevel ( Debug::type t)
inlinenoexcept

Deletes t from the current debug level.

◆ level() [1/2]

Debug::type DebugStream::level ( ) const
inlinenoexcept

Returns the current debug level.

◆ level() [2/2]

void DebugStream::level ( Debug::type t)
inlinenoexcept

Sets the debug level to t.

◆ logFile()

void DebugStream::logFile ( const std::string & f,
bool truncate = false )
virtual

Sets the debugstreams' logfile to f.

Переопределяется в uniset::LogAgregator.

◆ operator()()

std::ostream & DebugStream::operator() ( Debug::type t)
noexcept

Вывод продолжения логов (без даты и времени) "log()"

◆ operator[]()

std::ostream & DebugStream::operator[] ( Debug::type t)
inlinenoexcept

This is an operator to give a more convenient use: dbgstream[Debug::INFO] << "Info!\n"; Вывод осуществляется с датой и временем (если они не отключены)

◆ to_end()

std::ostream & DebugStream::to_end ( Debug::type t)
inlinenoexcept

Вывод продолжения логов (без даты и времени)

◆ verbose()

Debug::verbosity DebugStream::verbose ( ) const
inlinenoexcept

Returns the current verbose level.

Данные класса

◆ dt

Debug::type DebugStream::dt = { Debug::NONE }
protected

The current debug level.

◆ nullstream

std::ostream DebugStream::nullstream
protected

The no-op stream.