123 lines
3.1 KiB
C++
123 lines
3.1 KiB
C++
#ifndef JKLOG_JKLOG_H
|
|
#define JKLOG_JKLOG_H
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
#define JK_ERROR 1 << 4
|
|
#define JK_WARN 1 << 3
|
|
#define JK_INFO 1 << 2
|
|
#define JK_DEBUG 1 << 1
|
|
#define JK_VERBOSE 1 << 0
|
|
|
|
#define JK_DEFAULT_LOG_LEVEL JK_ERROR | JK_WARN
|
|
|
|
#ifndef LOG_LEVEL
|
|
#ifdef MIN_LOG_LEVEL_NONE
|
|
#define LOG_LEVEL 0
|
|
#endif //MIN_LOG_LEVEL_NONE
|
|
#endif //LOG_LEVEL
|
|
|
|
#ifndef LOG_LEVEL
|
|
#ifdef MIN_LOG_LEVEL_VERBOSE
|
|
#define LOG_LEVEL JK_ERROR | JK_WARN | JK_INFO | JK_DEBUG | JK_VERBOSE
|
|
#define JK_LOG_ERROR
|
|
#define JK_LOG_WARN
|
|
#define JK_LOG_INFO
|
|
#define JK_LOG_DEBUG
|
|
#define JK_LOG_VERBOSE
|
|
#endif //MIN_LOG_LEVEL_VERBOSE
|
|
#endif //LOG_LEVEL
|
|
|
|
#ifndef LOG_LEVEL
|
|
#ifdef MIN_LOG_LEVEL_DEBUG
|
|
#define LOG_LEVEL JK_ERROR | JK_WARN | JK_INFO | JK_DEBUG
|
|
#define JK_LOG_ERROR
|
|
#define JK_LOG_WARN
|
|
#define JK_LOG_INFO
|
|
#define JK_LOG_DEBUG
|
|
#endif //MIN_LOG_LEVEL_DEBUG
|
|
#endif //LOG_LEVEL
|
|
|
|
#ifndef LOG_LEVEL
|
|
#ifdef MIN_LOG_LEVEL_INFO
|
|
#define LOG_LEVEL JK_ERROR | JK_WARN | JK_INFO
|
|
#define JK_LOG_ERROR
|
|
#define JK_LOG_WARN
|
|
#define JK_LOG_INFO
|
|
#endif //MIN_LOG_LEVEL_INFO
|
|
#endif //LOG_LEVEL
|
|
|
|
#ifndef LOG_LEVEL
|
|
#ifdef MIN_LOG_LEVEL_WARN
|
|
#define LOG_LEVEL JK_ERROR | JK_WARN
|
|
#define JK_LOG_ERROR
|
|
#define JK_LOG_WARN
|
|
#endif //MIN_LOG_LEVEL_WARN
|
|
#endif //LOG_LEVEL
|
|
|
|
#ifndef LOG_LEVEL
|
|
#ifdef MIN_LOG_LEVEL_ERROR
|
|
#define LOG_LEVEL JK_ERROR
|
|
#define JK_LOG_WARN
|
|
#endif //MIN_LOG_LEVEL_ERROR
|
|
#endif //LOG_LEVEL
|
|
|
|
#ifndef LOG_LEVEL
|
|
#define LOG_LEVEL JK_DEFAULT_LOG_LEVEL
|
|
#endif //LOG_LEVEL
|
|
|
|
#ifdef JK_LOG_ERROR
|
|
#define Error(message) JkLog::error(__FILE__, __LINE__, message)
|
|
#else //JK_LOG_ERROR
|
|
#define Error(message) do {} while(false)
|
|
#endif //JK_LOG_ERROR
|
|
|
|
#ifdef JK_LOG_WARN
|
|
#define Warn(message) JkLog::warn(__FILE__, __LINE__, message)
|
|
#else //JK_LOG_WARN
|
|
#define Warn(message) do {} while(false)
|
|
#endif //JK_LOG_WARN
|
|
|
|
#ifdef JK_LOG_INFO
|
|
#define Info(message) JkLog::info(__FILE__, __LINE__, message)
|
|
#else //JK_LOG_INFO
|
|
#define Info(message) do {} while(false)
|
|
#endif //JK_LOG_INFO
|
|
|
|
#ifdef JK_LOG_DEBUG
|
|
#define Debug(message) JkLog::debug(__FILE__, __LINE__, message)
|
|
#else //JK_LOG_DEBUG
|
|
#define Debug(message) do {} while(false)
|
|
#endif //JK_LOG_DEBUG
|
|
|
|
#ifdef JK_LOG_VERBOSE
|
|
#define Verbose(message) JkLog::verbose(__FILE__, __LINE__, message)
|
|
#else //JK_LOG_VERBOSE
|
|
#define Verbose(message) do {} while(false)
|
|
#endif //JK_LOG_VERBOSE
|
|
|
|
|
|
class JkLog {
|
|
public:
|
|
JkLog();
|
|
|
|
static JkLog* getInstance();
|
|
static void setInstance(JkLog* instance);
|
|
static void error(const std::string& file, int line, const std::string& message);
|
|
static void warn(const std::string& file, int line, const std::string& message);
|
|
static void info(const std::string& file, int line, const std::string& message);
|
|
static void debug(const std::string& file, int line, const std::string& message);
|
|
static void verbose(const std::string& file, int line, const std::string& message);
|
|
static void log(int logLevel, const std::string& file, int line, const std::string& message);
|
|
virtual void log_impl(int logLevel, const std::string& file, int line, const std::string& message) const;
|
|
|
|
virtual ~JkLog();
|
|
|
|
protected:
|
|
static JkLog* instance;
|
|
};
|
|
|
|
|
|
#endif //JKLOG_JKLOG_H
|