#include <DebugPrinter.hpp>
Class for global static dout
object.
For details, consult the Member Function Documentation of fsc::DebugPrinter, the Macros section of DebugPrinter.hpp, as well as the Examples.
In case the program terminates with SIGSEGV
, SIGSYS
, SIGABRT
or SIGFPE
, you will automatically get a stack trace from the raise location. To turn off this behaviour, check the Compilation section.
Definition at line 154 of file DebugPrinter.hpp.
Public Member Functions | |
DebugPrinter () | |
Constructor for dout and user specified DebugPrinter objects. | |
DebugPrinter (const DebugPrinter &)=delete | |
Deleted copy constructor. | |
DebugPrinter (DebugPrinter &&)=delete | |
Deleted move constructor. | |
void | operator= (std::ostream &os) noexcept |
Assignment operator for changing streams. More... | |
template<typename T > | |
auto | operator= (T &&os) -> std::enable_if_t< std::is_move_assignable< T >::value &&std::is_rvalue_reference< decltype(os)>::value > |
Assignment operator for moving streams. More... | |
void | set_precision (const std::streamsize prec) noexcept |
Number of displayed decimal digits. More... | |
void | set_color (const std::string str) |
Highlighting color. More... | |
void | set_color () noexcept |
Remove highlighting color. More... | |
template<typename T , typename U > | |
void | operator() (const T &label, U const &obj, const std::string sc=": ") const |
Print highlighted label and object. More... | |
template<typename T > | |
void | operator() (const T &obj) const |
Print highlighted object. More... | |
void | stack (const int backtrace_size=max_backtrace, const bool compact=false, const int begin=1) const |
Print a stack trace. More... | |
Friends | |
template<typename T > | |
DebugPrinter & | operator<< (DebugPrinter &, const T &) |
operator<< overload for std::ostream | |
DebugPrinter & | operator<< (DebugPrinter &, std::ostream &(*pf)(std::ostream &)) |
operator<< overload for std::ostream manipulators | |
|
inline |
Print highlighted label and object.
label | should have a std::ostream & operator<< overload |
obj | should have a std::ostream & operator<< overload |
sc | delimiter between label and object |
If label
or obj
don't have the required operator << overloads, the function will print an error instead. Example usage:
Definition at line 284 of file DebugPrinter.hpp.
|
inline |
Print highlighted object.
obj | should have a std::ostream & operator<< overload |
Equivalent to
Example usage:
Definition at line 300 of file DebugPrinter.hpp.
|
inlinenoexcept |
Assignment operator for changing streams.
os | output stream to use |
Default == std::cout
. Change to any std::ostream
with:
The DebugPrinter assumes that the object is managed elsewhere (to have it take ownership, check the assigment operator for moving streams).
Definition at line 204 of file DebugPrinter.hpp.
|
inline |
Assignment operator for moving streams.
os | output stream to take over |
Use to pass ownership if the stream object would leave scope.
Note: trying to move std::cout
(or other static standard streams) is considered a bad life choice.
Definition at line 221 of file DebugPrinter.hpp.
|
inline |
Highlighting color.
str | color code |
Assumes a bash
compatible terminal and sets the operator()
highlighting color (also used for dout_HERE
and dout_VAL
), for example red == "0;31" (default). Example usage:
For bash color codes check http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
Definition at line 249 of file DebugPrinter.hpp.
|
inlinenoexcept |
Remove highlighting color.
No color highlighting (e.g. when writing to a file). Example usage:
Definition at line 263 of file DebugPrinter.hpp.
|
inlinenoexcept |
Number of displayed decimal digits.
prec | desired precision |
Default == 5. Example usage:
Definition at line 235 of file DebugPrinter.hpp.
|
inline |
Print a stack trace.
backtrace_size | print at most this many frames |
compact | only print function names |
begin | starting offset |
Print one line per stack frame, consisting of the binary object name, the demangled function name, and the offset within the function and within the binary. Example usage:
Definition at line 324 of file DebugPrinter.hpp.