#include "journalloglevel.h"
#include "abstractadditionallogger.h"
#include <sstream>
#include <iomanip>
#include <xstypes/xsstring.h>
#include <memory>
Go to the source code of this file.
Classes | |
class | JlHexLogger< T > |
A support class of journaller that is used for the logging of hex values. More... | |
class | Journaller |
A journalling class for debugging applications. More... | |
class | JournalValueJanitor< T > |
Class for journalling a referenced value when the janitor leaves scope. More... | |
Macros | |
#define | JLALERT(...) ((void)0) |
#define | JLALERT_NODEC(...) ((void)0) |
#define | JLALERTG(msg) JLALERT(gJournal, msg) |
#define | JLCASE(s, a) case a: s << #a << "(" << static_cast<int>(a) << ")"; break; |
#define | JLCASE2(s, a, b) case a: s << b << "(" << static_cast<int>(a) << ")"; break; |
#define | JLDEBUG(...) ((void)0) |
#define | JLDEBUG_NODEC(...) ((void)0) |
#define | JLDEBUGFINAL(journal, a) JLFINALVALUE(journal, JLL_Debug, a) |
#define | JLDEBUGFINALG(a) JLDEBUGFINAL(gJournal, a) |
#define | JLDEBUGG(msg) JLDEBUG(gJournal, msg) |
#define | JLDEFAULTCASE(s) default: s << "Unknown case: " << static_cast<int>(e); break; |
#define | JLENUMCASE(a) JLCASE(dbg, a) |
#define | JLENUMCASE2(a, b) JLCASE2(dbg, a, b) |
#define | JLENUMCASEBITS(a) if ((static_cast<int>(e) & static_cast<int>(a)) == static_cast<int>(a)) { if (first) first = false; else dbg << " | "; dbg << #a << "(" << static_cast<int>(a) << ")"; } |
#define | JLENUMCASEBITSNONE(a) if (first) { dbg << #a << "(0)"; first = false; } |
#define | JLENUMEXPANDER(E, items) JLENUMEXPHDR(E) items JLENUMEXPFTR() |
#define | JLENUMEXPANDERBITS(E, items) /*! \brief Translate \a e into a text representation */ JLENUMEXPPROTO(E) { bool first = true; dbg << std::hex << std::uppercase << static_cast<int>(e) << "="; items if (first) dbg << "<None>"; dbg << std::dec << std::nouppercase; return dbg; } |
#define | JLENUMEXPANDERHEX(E, items) JLENUMEXPHDR(E, dbg << std::hex << std::uppercase;) items JLENUMEXPFTR(dbg << std::dec << std::nouppercase;) |
#define | JLENUMEXPFTR(...) JLDEFAULTCASE(dbg) } __VA_ARGS__ return dbg; } |
#define | JLENUMEXPHDR(E, ...) /*! \brief Translate \a e into a text representation */ JLENUMEXPPROTO(E) { __VA_ARGS__ switch(e) { |
#define | JLENUMEXPPROTO(E) std::ostream& operator << (std::ostream& dbg, E const& e) |
#define | JLERROR(journal, msg) JLGENERIC(journal, JLL_Error, msg) |
#define | JLERROR_NODEC(journal, msg) JLGENERIC_NODEC(journal, JLL_Error, msg) |
#define | JLERRORG(msg) JLERROR(gJournal, msg) |
#define | JLFATAL(journal, msg) JLGENERIC(journal, JLL_Fatal, msg) |
#define | JLFATAL_NODEC(journal, msg) JLGENERIC_NODEC(journal, JLL_Fatal, msg) |
#define | JLFATALG(msg) JLFATAL(gJournal, msg) |
#define | JLFINALNAME(a) #a ": " |
#define | JLFINALVALUE(journal, level, a) JournalValueJanitor<decltype(a)> jlFinalValue ## a(journal, a, [](char const* fi, char const* fu, char const* va) { std::stringstream os; os << fi << " " << fu << " exit " << va; return os.str(); }(__FILE__, __FUNCTION__, JLFINALNAME(a)), level, true) |
#define | JLGENERIC(journal, level, msg) |
#define | JLGENERIC_LINEINFO "" |
#define | JLGENERIC_NODEC(journal, level, msg) |
#define | JLHEXLOG(d) "0x" << JLHEXLOG_BARE(d) |
#define | JLHEXLOG_BARE(d) JlHexLogger<decltype(d)>(d) |
#define | JLIF(journal, level, todo) do { if (journal && journal->logLevel(level)) { todo; } } while(0) |
#define | JLINSTALLQTDEBUGHANDLER(journal) |
#define | JLPRECISE(msg) JLPRECISE2(msg, 16) |
#define | JLPRECISE2(msg, prec) |
#define | JLQTDEBUGHANDLER |
#define | JLTRACE(...) ((void)0) |
#define | JLTRACE_NODEC(...) ((void)0) |
#define | JLTRACEG(msg) JLTRACE(gJournal, msg) |
#define | JLVARLOG(a) #a ": " << a << " " |
#define | JLWRITE(journal, msg) JLGENERIC(journal, JLL_Write, msg) |
#define | JLWRITE_NODEC(journal, msg) JLGENERIC_NODEC(journal, JLL_Write, msg) |
#define | JLWRITEFINAL(journal, a) JLFINALVALUE(journal, JLL_Write, a) |
#define | JLWRITEFINALG(a) JLWRITEFINAL(gJournal, a) |
#define | JLWRITEG(msg) JLWRITE(gJournal, msg) |
#define | STRIPPEDFILE jlStrippedPathFile(__FILE__) |
Functions | |
static constexpr char const * | jlStrippedPath (char const *a, char const *b) |
static constexpr char const * | jlStrippedPathFile (char const *a) |
void | jlTerminate (Journaller **gj) |
Cleans up any remaining stuff. More... | |
template<> | |
std::ostream & | operator<< (std::ostream &os, JlHexLogger< char > const &hex) |
template<typename T > | |
std::ostream & | operator<< (std::ostream &os, JlHexLogger< T > const &hex) |
#define JLALERT | ( | ... | ) | ((void)0) |
Definition at line 247 of file journaller.h.
#define JLALERT_NODEC | ( | ... | ) | ((void)0) |
Definition at line 248 of file journaller.h.
Definition at line 348 of file journaller.h.
Definition at line 347 of file journaller.h.
#define JLDEBUG | ( | ... | ) | ((void)0) |
Definition at line 239 of file journaller.h.
#define JLDEBUG_NODEC | ( | ... | ) | ((void)0) |
Definition at line 240 of file journaller.h.
#define JLDEBUGFINAL | ( | journal, | |
a | |||
) | JLFINALVALUE(journal, JLL_Debug, a) |
Definition at line 292 of file journaller.h.
#define JLDEBUGFINALG | ( | a | ) | JLDEBUGFINAL(gJournal, a) |
Definition at line 293 of file journaller.h.
Definition at line 349 of file journaller.h.
#define JLENUMCASE | ( | a | ) | JLCASE(dbg, a) |
Definition at line 352 of file journaller.h.
#define JLENUMCASE2 | ( | a, | |
b | |||
) | JLCASE2(dbg, a, b) |
Definition at line 353 of file journaller.h.
#define JLENUMCASEBITS | ( | a | ) | if ((static_cast<int>(e) & static_cast<int>(a)) == static_cast<int>(a)) { if (first) first = false; else dbg << " | "; dbg << #a << "(" << static_cast<int>(a) << ")"; } |
Definition at line 366 of file journaller.h.
#define JLENUMCASEBITSNONE | ( | a | ) | if (first) { dbg << #a << "(0)"; first = false; } |
Definition at line 367 of file journaller.h.
#define JLENUMEXPANDER | ( | E, | |
items | |||
) | JLENUMEXPHDR(E) items JLENUMEXPFTR() |
Use this macro to define enum expansion to a text stream, items will show up as "EnumName (decimal value)". supply the type as parameter E and all enum values you want to expand as a sequence of JLENUMCASE(item) (no commas)
Definition at line 357 of file journaller.h.
#define JLENUMEXPANDERBITS | ( | E, | |
items | |||
) | /*! \brief Translate \a e into a text representation */ JLENUMEXPPROTO(E) { bool first = true; dbg << std::hex << std::uppercase << static_cast<int>(e) << "="; items if (first) dbg << "<None>"; dbg << std::dec << std::nouppercase; return dbg; } |
Use this macro to define enum bit field expansion to a text stream, items will show up as "full hex=EnumName1(hex) | EnumName2(hex)". supply the type as parameter E and all enum values you want to expand as a sequence of JLENUMCASEBITS(item) (no commas)
Definition at line 365 of file journaller.h.
#define JLENUMEXPANDERHEX | ( | E, | |
items | |||
) | JLENUMEXPHDR(E, dbg << std::hex << std::uppercase;) items JLENUMEXPFTR(dbg << std::dec << std::nouppercase;) |
Use this macro to define enum expansion to a text stream, items will show up as "EnumName (hexadecimal value)". supply the type as parameter E and all enum values you want to expand as a sequence of JLENUMCASE(item) (no commas)
Definition at line 361 of file journaller.h.
#define JLENUMEXPFTR | ( | ... | ) | JLDEFAULTCASE(dbg) } __VA_ARGS__ return dbg; } |
Definition at line 354 of file journaller.h.
#define JLENUMEXPHDR | ( | E, | |
... | |||
) | /*! \brief Translate \a e into a text representation */ JLENUMEXPPROTO(E) { __VA_ARGS__ switch(e) { |
Definition at line 351 of file journaller.h.
#define JLENUMEXPPROTO | ( | E | ) | std::ostream& operator << (std::ostream& dbg, E const& e) |
Definition at line 350 of file journaller.h.
Definition at line 258 of file journaller.h.
#define JLERROR_NODEC | ( | journal, | |
msg | |||
) | JLGENERIC_NODEC(journal, JLL_Error, msg) |
Definition at line 259 of file journaller.h.
Definition at line 266 of file journaller.h.
#define JLFATAL_NODEC | ( | journal, | |
msg | |||
) | JLGENERIC_NODEC(journal, JLL_Fatal, msg) |
Definition at line 267 of file journaller.h.
#define JLFINALNAME | ( | a | ) | #a ": " |
Definition at line 288 of file journaller.h.
#define JLFINALVALUE | ( | journal, | |
level, | |||
a | |||
) | JournalValueJanitor<decltype(a)> jlFinalValue ## a(journal, a, [](char const* fi, char const* fu, char const* va) { std::stringstream os; os << fi << " " << fu << " exit " << va; return os.str(); }(__FILE__, __FUNCTION__, JLFINALNAME(a)), level, true) |
Definition at line 289 of file journaller.h.
#define JLGENERIC | ( | journal, | |
level, | |||
msg | |||
) |
Definition at line 196 of file journaller.h.
#define JLGENERIC_LINEINFO "" |
Definition at line 193 of file journaller.h.
#define JLGENERIC_NODEC | ( | journal, | |
level, | |||
msg | |||
) |
Definition at line 212 of file journaller.h.
Definition at line 335 of file journaller.h.
#define JLHEXLOG_BARE | ( | d | ) | JlHexLogger<decltype(d)>(d) |
Definition at line 331 of file journaller.h.
#define JLIF | ( | journal, | |
level, | |||
todo | |||
) | do { if (journal && journal->logLevel(level)) { todo; } } while(0) |
Definition at line 298 of file journaller.h.
#define JLINSTALLQTDEBUGHANDLER | ( | journal | ) |
Definition at line 396 of file journaller.h.
#define JLPRECISE | ( | msg | ) | JLPRECISE2(msg, 16) |
Definition at line 345 of file journaller.h.
#define JLPRECISE2 | ( | msg, | |
prec | |||
) |
Definition at line 338 of file journaller.h.
#define JLQTDEBUGHANDLER |
Definition at line 369 of file journaller.h.
#define JLTRACE | ( | ... | ) | ((void)0) |
Definition at line 231 of file journaller.h.
#define JLTRACE_NODEC | ( | ... | ) | ((void)0) |
Definition at line 232 of file journaller.h.
#define JLVARLOG | ( | a | ) | #a ": " << a << " " |
Definition at line 336 of file journaller.h.
Definition at line 274 of file journaller.h.
#define JLWRITE_NODEC | ( | journal, | |
msg | |||
) | JLGENERIC_NODEC(journal, JLL_Write, msg) |
Definition at line 275 of file journaller.h.
#define JLWRITEFINAL | ( | journal, | |
a | |||
) | JLFINALVALUE(journal, JLL_Write, a) |
Definition at line 290 of file journaller.h.
#define JLWRITEFINALG | ( | a | ) | JLWRITEFINAL(gJournal, a) |
Definition at line 291 of file journaller.h.
#define STRIPPEDFILE jlStrippedPathFile(__FILE__) |
Definition at line 185 of file journaller.h.
|
inlinestaticconstexpr |
Definition at line 177 of file journaller.h.
|
inlinestaticconstexpr |
Definition at line 181 of file journaller.h.
void jlTerminate | ( | Journaller ** | gj | ) |
Cleans up any remaining stuff.
The function assumes that no new log lines will be created anymore
gj | Optional pointer to Journaller pointer to be cleaned up, usually &gJournal should be provided. The pointer that gj points to will be set to nullptr. |
Definition at line 505 of file journaller.cpp.
std::ostream& operator<< | ( | std::ostream & | os, |
JlHexLogger< char > const & | hex | ||
) |
Definition at line 388 of file journaller.cpp.
std::ostream& operator<< | ( | std::ostream & | os, |
JlHexLogger< T > const & | hex | ||
) |
Definition at line 323 of file journaller.h.