#ifndef LOGGER_H #define LOGGER_H #include "makestring.h" enum LogLevel { LogDebug = 0, LogInfo, LogWarning, LogError, LogFatal }; void log(LogLevel level, const std::string& message, std::string prettyFunction = ""); // specialized logging template void debug(const T&... args) { log(LogInfo, make_string(args...)); } template void info(const T&... args) { log(LogDebug, make_string(args...)); } template void warning(const T&... args) { log(LogWarning, make_string(args...)); } template void error(const T&... args) { log(LogError, make_string(args...)); } template void fatal(const T&... args) { log(LogFatal, make_string(args...)); } #define trace() log(LogDebug, "", __PRETTY_FUNCTION__) // dump utility struct Dump { ~Dump() { debug(s.str().c_str()); } template Dump& operator<<(const T& v) { s << v << " "; return *this; } std::ostringstream s; }; #define dump Dump() #endif // LOGGER_H