ES-DE/es-core/src/Log.h
2020-07-13 20:58:25 +02:00

49 lines
734 B
C++

//
// Log.h
//
// Log handling.
//
#pragma once
#ifndef ES_CORE_LOG_H
#define ES_CORE_LOG_H
#include <sstream>
#define LOG(level) \
if (level > Log::getReportingLevel()); \
else Log().get(level)
enum LogLevel {
LogError,
LogWarning,
LogInfo,
LogDebug
};
class Log
{
public:
~Log();
std::ostringstream& get(LogLevel level = LogInfo);
static LogLevel getReportingLevel();
static void setReportingLevel(LogLevel level);
static std::string getLogPath();
static void flush();
static void init();
static void open();
static void close();
protected:
std::ostringstream os;
private:
static LogLevel reportingLevel;
LogLevel messageLevel;
};
#endif // ES_CORE_LOG_H