tibia-client/src/framework/util/logger.h

39 lines
1005 B
C
Raw Normal View History

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