11 #include <type_traits>
16 #ifndef MERCURYDPM_LOGLEVEL
17 #define MERCURYDPM_LOGLEVEL Log::DEFAULT
21 #define CG_LOGLEVEL Log::DEFAULT
29 #ifdef MERCURYDPM_FORCE_ASSERTS
30 #define MERCURYDPM_ASSERTS true
32 #ifdef MERCURYDPM_NO_ASSERTS
33 #define MERCURYDPM_ASSERTS false
36 #define MERCURYDPM_ASSERTS false
38 #define MERCURYDPM_ASSERTS true
121 return ((
static_cast<signed char>(rhs)) <= (
static_cast<signed char>(lhs)));
157 template<Log L = Log::DEFAULT,
bool ASSERTS = MERCURYDPM_ASSERTS>
282 template<Log L,
bool ASSERTS>
328 template<
Log LOGLEVEL,
typename ... Args>
332 std::stringstream msgstream;
367 template<
Log LOGLEVEL,
typename... Args>
378 template<
Log LOGLEVEL,
typename... Args>
399 template<
typename... Args>
400 typename std::enable_if<(
ASSERTS) && (
sizeof...(Args) >= 0),
void>::
type
401 assert_debug(
bool assertion,
const char*
format, Args&& ... arg)
403 assert_always(assertion,
format, arg...);
406 template<
typename... Args>
407 typename std::enable_if<!((
ASSERTS) &&
sizeof...(Args) >= 0),
void>::
type
408 assert_debug(
bool assertion,
const char*
format, Args&& ... arg)
416 template<
typename... Args>
419 assert_debug(assertion,
format.c_str(), arg...);
422 template<
typename... Args>
423 void assert_always(
bool assertion,
const char*
format, Args&& ... arg)
427 std::stringstream msgstream;
437 template<
typename... Args>
440 assert_always(assertion,
format.c_str(), arg...);
447 template<
typename... Args>
453 std::stringstream msgstream;
502 template<
typename Arg1,
typename... Args>
504 Arg1&& arg, Args&& ...
args)
506 bool doSkipNext =
false;
507 while (*fmt !=
'%' || doSkipNext)
513 if (*fmt ==
'\\' && !doSkipNext)
531 precision = std::atoi(fmt);
532 while (isdigit(*fmt))
536 if (std::ispunct(*fmt))
539 if (std::isdigit(*fmt))
541 width = std::atoi(fmt);
542 while (isdigit(*fmt))
555 else if (std::ispunct(*fmt))
558 if (std::isdigit(*fmt))
560 width = std::atoi(fmt);
561 while (isdigit(*fmt))
572 if (width != 0 && precision != 0)
574 msg << std::setprecision(precision) << std::left << std::setw(width) << arg;
576 else if (precision != 0)
578 msg << std::setprecision(precision) << arg;
582 msg << std::left << std::setw(width) << arg;
604 template<
typename... Args>
610 #ifndef MERCURYDPM_DEBUG
630 template<
typename Arg1>
633 bool doSkipNext =
false;
634 while (*fmt !=
'%' || doSkipNext)
639 if (*fmt ==
'\\' && !doSkipNext)
657 precision = std::atoi(fmt);
658 while (isdigit(*fmt))
662 if (std::ispunct(*fmt))
665 if (std::isdigit(*fmt))
667 width = std::atoi(fmt);
668 while (isdigit(*fmt))
681 else if (std::ispunct(*fmt))
684 if (std::isdigit(*fmt))
686 width = std::atoi(fmt);
687 while (isdigit(*fmt))
698 if (width != 0 && precision != 0)
700 msg << std::setprecision(precision) << std::left << std::setw(width) << arg << fmt;
702 else if (precision != 0)
704 msg << std::setprecision(precision) << arg << fmt;
708 msg << std::left << std::setw(width) << arg << fmt;
743 #if !MERCURYDPM_ASSERTS
744 #define assert(e,...) assert(true,"")
747 #ifdef MERCURYDPM_USE_MPI
#define MERCURYDPM_DEPRECATED
Definition: GeneralDefine.h:16
#define UNUSED
Definition: GeneralDefine.h:18
MatrixXd L
Definition: LLT_example.cpp:6
Logger< CG_LOGLEVEL > cgLogger
LL< Log::VERBOSE > VERBOSE
Verbose information.
Definition: Logger.cc:36
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:34
LL< Log::DEBUG > DEBUG
Debug information.
Definition: Logger.cc:37
Log
The different loglevels.
Definition: Logger.h:109
LL< Log::FATAL > FATAL
Fatal log level.
Definition: Logger.cc:31
Flusher
The Logger class provides ability to write log messages in your own customized format.
Definition: Logger.h:94
#define MERCURYDPM_LOGLEVEL
Definition: Logger.h:17
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:32
LoggerOutput * loggerOutput
Declaration of the output functions.
Definition: Logger.cc:262
Logger< MERCURYDPM_LOGLEVEL > logger
constexpr bool operator<=(const Log rhs, const Log lhs)
Internally used to filter on loglevel. Do not edit, as this is required for an optimised logger.
Definition: Logger.h:119
LL< Log::WARN > WARN
Warning log level.
Definition: Logger.cc:33
LL< Log::DEFAULT > DEFAULT
Default log level.
Definition: Logger.cc:35
Tag for template metaprogramming.
Definition: Logger.h:174
Default functions for output generation.
Definition: Logger.h:136
std::function< void(std::string, std::string, Flusher)> onVerbose
Definition: Logger.h:142
std::function< void(std::string, std::string, Flusher)> onFatal
Definition: Logger.h:138
std::function< void(std::string, std::string, Flusher)> onWarn
Definition: Logger.h:140
std::function< void(std::string, std::string, Flusher)> onError
Definition: Logger.h:139
std::function< void(std::string, std::string, Flusher)> onInfo
Definition: Logger.h:141
std::function< void(std::string, std::string, Flusher)> onDebug
Definition: Logger.h:143
the Logger class is the main class of the logger implementation. It holds all the functions which inv...
Definition: Logger.h:284
void createMessage(std::stringstream &msg, const char *fmt, Flusher arg, Args &&... args)
Overloaded version of createMessage to catch arguments of Flusher and suppress input flushing via std...
Definition: Logger.h:605
const std::string module
The module name of this actual logger.
Definition: Logger.h:290
void createMessage(std::stringstream &msg, const char *fmt, Arg1 &&arg)
Terminating case / Argument call. Overloaded function for a logger message with only one argument or ...
Definition: Logger.h:631
void createMessage(std::stringstream &msg, const char *message)
Terminating case / no argument call Overloaded function for a logger message without arguments.
Definition: Logger.h:724
Logger(const std::string name)
constructor
Definition: Logger.h:304
~Logger()=default
destructor
std::enable_if<!((L< LOGLEVEL) &&(MERCURYDPM_LOGLEVEL< LOGLEVEL)), void >::type operator()(const LL< LOGLEVEL > log, const char *format UNUSED, Args &&... arg UNUSED)
Log implementation of this function.
Definition: Logger.h:330
Flusher doFlush_
Can prevent the logger from flushing the buffer via std::endl. doFlush_ is set automatically based on...
Definition: Logger.h:295
void createMessage(std::stringstream &msg, const char *fmt, Arg1 &&arg, Args &&... args)
Edits the message to a certain format and writes it to a stringstream by recursively replacing all % ...
Definition: Logger.h:503
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log(const bfloat16 &a)
Definition: BFloat16.h:618
args
Definition: compute_granudrum_aor.py:143
type
Definition: compute_granudrum_aor.py:141
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
string name
Definition: plotDoE.py:33
#define ASSERTS(expr)
Definition: oomph_parmetis_3.1.1/macros.h:118
std::string format(const std::string &str, const std::vector< std::string > &find, const std::vector< std::string > &replace)
Definition: openglsupport.cpp:217