MercuryDPM
Alpha
|
See How to use the logger for details on how to use the logger. More...
#include <Logger.h>
Public Member Functions | |
Logger (const std::string name) | |
constructor More... | |
~Logger () | |
destructor More... | |
template<Log LOGLEVEL, typename... Args> | |
std::enable_if<!((L< LOGLEVEL)&&(MERCURY_LOGLEVEL < LOGLEVEL)), void >::type | operator() (const LL< LOGLEVEL > log, const char *format, Args &&...arg) |
template<Log LOGLEVEL, typename... Args> | |
std::enable_if< L< LOGLEVEL||MERCURY_LOGLEVEL < LOGLEVEL, void >::type operator()(const LL< LOGLEVEL > log UNUSED, const std::string &format UNUSED, Args &&...arg UNUSED){}template< Log LOGLEVEL, typename...Args > typename std::enable_if< L < LOGLEVEL||MERCURY_LOGLEVEL < LOGLEVEL, void >::type operator()(const LL< LOGLEVEL > log UNUSED, const char *format UNUSED, Args &&...arg UNUSED){}template < typename...Args > typename std::enable_if<(ASSERTS)&&(sizeof...(Args) > =0), void >::type assert(bool assertion, const char *format, Args &&...arg){assert_always(assertion, format, arg...);}template < typename...Args > typename std::enable_if<!((ASSERTS)&&sizeof...(Args) > =0), void >::type assert(bool assertion, const char *format, Args &&...arg){}template < typename...Args > void assert(bool assertion, const std::string format, Args &&...arg){assert(assertion, format.c_str(), arg...);}template < typename...Args > void assert_always(bool assertion, const char *format, Args &&...arg){if(!assertion){std::stringstream msgstream;createMessage(msgstream, format, arg...);loggerOutput-> onFatal(module, msgstream.str());}}template < typename...Args > void assert_always(bool assertion, const std::string format, Args &&...arg){assert_always(assertion, format.c_str(), arg...);}template < typename...Args > void log(const Log loglevel, const std::string &format, Args &&...arg){if(loglevel<=L||loglevel <=MERCURY_LOGLEVEL){std::stringstream msgstream;createMessage(msgstream, format.c_str(), arg...);if(loglevel <=Log::FATAL){loggerOutput-> onFatal(module, msgstream.str());}else if(loglevel<=Log::ERROR){loggerOutput-> onError(module, msgstream.str());}else if(loglevel<=Log::WARN){loggerOutput-> | onWarn (module, msgstream.str()) |
else | if (loglevel<=Log::INFO) |
else | if (loglevel<=Log::VERBOSE) |
Public Attributes | |
else | |
Private Member Functions | |
template<typename Arg1 , typename... Args> | |
void | createMessage (std::stringstream &msg, const char *fmt, Arg1 &&arg, Args &&...args) |
Actual implementation to recursively replace all the '' signs by actual values. More... | |
template<typename Arg1 > | |
void | createMessage (std::stringstream &msg, const char *fmt, Arg1 &&arg) |
Terminating case / argument call. More... | |
void | createMessage (std::stringstream &msg, const char *message) |
Terminating case / no argument call. More... | |
Private Attributes | |
const std::string | module |
The module name of this actual logger. More... | |
See How to use the logger for details on how to use the logger.
Usage: logger(FATAL, "Error in (here) because % < %!\n", var1, var2);
Define custom loggers by: #ifndef HG_LOGLEVEL_CUSTOMMOD #define HG_LOGLEVEL_CUSTOMMOD Log::Debug #endif Logger<HG_LOGLEVEL_CUSTOMMOD> customLogger;
|
inline |
constructor
Definition at line 329 of file Logger.h.
|
inlineprivate |
Actual implementation to recursively replace all the '' signs by actual values.
Definition at line 507 of file Logger.h.
Referenced by Logger< L, ASSERTS >::operator()().
|
inlineprivate |
|
inlineprivate |
|
inline |
Definition at line 487 of file Logger.h.
References Logger< L, ASSERTS >::module, and LoggerOutput::onInfo.
|
inline |
Definition at line 491 of file Logger.h.
References Logger< L, ASSERTS >::module, and LoggerOutput::onVerbose.
std::enable_if<L < LOGLEVEL || MERCURY_LOGLEVEL < LOGLEVEL, void>::type operator()(const LL<LOGLEVEL> log UNUSED, const std::string& format UNUSED, Args&&... arg UNUSED) { } template<Log LOGLEVEL, typename... Args> typename std::enable_if<L < LOGLEVEL || MERCURY_LOGLEVEL < LOGLEVEL, void>::type operator()(const LL<LOGLEVEL> log UNUSED, const char * format UNUSED, Args&&... arg UNUSED) { } template<typename... Args> typename std::enable_if<(ASSERTS) && (sizeof...(Args) >= 0), void>::type assert(bool assertion, const char* format, Args&&... arg) { assert_always(assertion, format, arg...); } template<typename... Args> typename std::enable_if<!((ASSERTS) && sizeof...(Args) >= 0), void>::type assert(bool assertion, const char* format, Args&&... arg) { } template<typename... Args> void assert(bool assertion, const std::string format, Args&&... arg) { assert(assertion, format.c_str(), arg...); } template<typename... Args> void assert_always(bool assertion, const char* format, Args&&... arg) { if (!assertion) { std::stringstream msgstream; createMessage(msgstream, format, arg...); loggerOutput->onFatal(module, msgstream.str()); } } template<typename... Args> void assert_always(bool assertion, const std::string format, Args&&... arg) { assert_always(assertion, format.c_str(), arg...); } template<typename... Args> void log(const Log loglevel, const std::string& format, Args&&... arg) { if (loglevel <= L || loglevel <= MERCURY_LOGLEVEL) { std::stringstream msgstream; createMessage(msgstream, format.c_str(), arg...); if (loglevel <= Log::FATAL) { loggerOutput->onFatal(module, msgstream.str()); } else if (loglevel <= Log::ERROR) { loggerOutput->onError(module, msgstream.str()); } else if (loglevel <= Log::WARN) { loggerOutput-> Logger< L, ASSERTS >::onWarn | ( | module | , |
msgstream. | str() | ||
) |
|
inline |
Definition at line 353 of file Logger.h.
References Logger< L, ASSERTS >::createMessage(), ERROR, FATAL, INFO, Logger< L, ASSERTS >::module, LoggerOutput::onDebug, LoggerOutput::onError, LoggerOutput::onFatal, LoggerOutput::onInfo, LoggerOutput::onVerbose, LoggerOutput::onWarn, VERBOSE, and WARN.
Logger< L, ASSERTS >::else |
|
private |
The module name of this actual logger.
Definition at line 321 of file Logger.h.
Referenced by Logger< L, ASSERTS >::if(), and Logger< L, ASSERTS >::operator()().