10 #ifndef MERCURY_LOGLEVEL
11 #define MERCURY_LOGLEVEL Log::DEFAULT
110 enum class Log : signed char {
125 return ((static_cast<signed char>(rhs)) <= (static_cast<signed char>(lhs)));
142 std::function<void(std::string,std::string)>
onFatal;
143 std::function<void(std::string,std::string)>
onError;
144 std::function<void(std::string,std::string)>
onWarn;
145 std::function<void(std::string,std::string)>
onInfo;
147 std::function<void(std::string,std::string)>
onDebug;
161 template<Log L = Log::DEFAULT>
class Logger;
304 template<
Log LOGLEVEL,
typename... Args>
305 typename std::enable_if<!((L < LOGLEVEL) || (MERCURY_LOGLEVEL < LOGLEVEL)), void>::type
307 std::stringstream msgstream;
324 template<
Log LOGLEVEL,
typename... Args>
325 typename std::enable_if<L < LOGLEVEL || MERCURY_LOGLEVEL < LOGLEVEL, void>::type
330 template<
Log LOGLEVEL,
typename... Args>
331 typename std::enable_if<!((L < LOGLEVEL) || (MERCURY_LOGLEVEL < LOGLEVEL)), void>::type
333 std::stringstream msgstream;
350 template<
Log LOGLEVEL,
typename... Args>
351 typename std::enable_if<L < LOGLEVEL || MERCURY_LOGLEVEL < LOGLEVEL, void>::type
361 template<
typename... Args>
362 void log(
const Log loglevel,
const std::string& format, Args&&... arg) {
364 std::stringstream msgstream;
386 template<
typename Arg1,
typename... Args>
388 Arg1&& arg, Args&&... args)
390 bool doSkipNext =
false;
391 while (*fmt !=
'%' && !doSkipNext)
417 template<
typename Arg1>
420 bool doSkipNext =
false;
421 while (*fmt !=
'%' && !doSkipNext)
LoggerOutput * loggerOutput
Declaration of the output functions. If the output needs to be redirected, please swap the loggerOutp...
LL< Log::INFO > INFO
Info log level.
LL< Log::DEBUG > DEBUG
Debug information.
LL< Log::ERROR > ERROR
Error log level.
const std::string module
The module name of this actual logger.
std::function< void(std::string, std::string)> onWarn
void createMessage(std::stringstream &msg, const char *message)
Terminating case / no argument call.
std::function< void(std::string, std::string)> onVerbose
Logger(const std::string name)
constructor
std::enable_if<!((L< LOGLEVEL)||(MERCURY_LOGLEVEL< LOGLEVEL)), void >::type operator()(const LL< LOGLEVEL > log UNUSED, const std::string &format, Args &&...arg)
void createMessage(std::stringstream &msg, const char *fmt, Arg1 &&arg)
Terminating case / argument call.
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...
void createMessage(std::stringstream &msg, const char *fmt, Arg1 &&arg, Args &&...args)
Actual implementation to recursively replace all the '' signs by actual values.
std::function< void(std::string, std::string)> onError
Default functions for output generation.
LL< Log::DEFAULT > DEFAULT
Default log level.
LL< Log::VERBOSE > VERBOSE
Verbose information.
std::function< void(std::string, std::string)> onDebug
Logger< MERCURY_LOGLEVEL > logger
std::function< void(std::string, std::string)> onInfo
Log
The different loglevels.
LL< Log::FATAL > FATAL
Fatal log level.
std::function< void(std::string, std::string)> onFatal
LL< Log::WARN > WARN
Warning log level.
Tag for template metaprogramming.