2017-10-31 17:12:50 +00:00
|
|
|
#pragma once
|
|
|
|
#ifndef ES_CORE_LOG_H
|
|
|
|
#define ES_CORE_LOG_H
|
2013-01-04 23:31:51 +00:00
|
|
|
|
2017-11-01 22:21:10 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
2013-01-04 23:31:51 +00:00
|
|
|
#define LOG(level) \
|
|
|
|
if(level > Log::getReportingLevel()) ; \
|
|
|
|
else Log().get(level)
|
|
|
|
|
|
|
|
enum LogLevel { LogError, LogWarning, LogInfo, LogDebug };
|
|
|
|
|
|
|
|
class Log
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//Log();
|
|
|
|
~Log();
|
|
|
|
std::ostringstream& get(LogLevel level = LogInfo);
|
|
|
|
|
|
|
|
static LogLevel getReportingLevel();
|
|
|
|
static void setReportingLevel(LogLevel level);
|
|
|
|
|
|
|
|
static std::string getLogPath();
|
|
|
|
|
|
|
|
static void flush();
|
2017-08-01 10:34:49 +00:00
|
|
|
static void init();
|
2013-01-08 02:24:59 +00:00
|
|
|
static void open();
|
2013-01-04 23:31:51 +00:00
|
|
|
static void close();
|
|
|
|
protected:
|
|
|
|
std::ostringstream os;
|
|
|
|
static FILE* file;
|
|
|
|
private:
|
|
|
|
static LogLevel reportingLevel;
|
|
|
|
static FILE* getOutput();
|
|
|
|
LogLevel messageLevel;
|
|
|
|
};
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#endif // ES_CORE_LOG_H
|