2014-07-21 17:58:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
class LogBase
|
|
|
|
|
{
|
|
|
|
|
bool m_logging;
|
2014-08-22 23:15:02 +02:00
|
|
|
bool CheckLogging() const;
|
2014-08-23 16:51:51 +02:00
|
|
|
|
|
|
|
|
enum LogType
|
|
|
|
|
{
|
|
|
|
|
LogNotice,
|
|
|
|
|
LogSuccess,
|
|
|
|
|
LogWarning,
|
|
|
|
|
LogError,
|
2015-01-18 23:54:56 +01:00
|
|
|
LogTodo,
|
2014-08-23 16:51:51 +02:00
|
|
|
};
|
|
|
|
|
|
2015-01-18 23:54:56 +01:00
|
|
|
void LogOutput(LogType type, const std::string& text) const;
|
|
|
|
|
|
2015-05-28 17:14:22 +02:00
|
|
|
template<typename... Args> never_inline void LogPrepare(LogType type, const char* fmt, Args... args) const
|
2015-01-18 23:54:56 +01:00
|
|
|
{
|
2015-03-07 14:39:07 +01:00
|
|
|
LogOutput(type, fmt::Format(fmt, args...));
|
2015-01-18 23:54:56 +01:00
|
|
|
}
|
2014-08-22 16:58:50 +02:00
|
|
|
|
2014-07-21 17:58:03 +02:00
|
|
|
public:
|
2014-07-21 18:39:00 +02:00
|
|
|
void SetLogging(bool value)
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2014-07-21 18:39:00 +02:00
|
|
|
m_logging = value;
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-21 18:39:00 +02:00
|
|
|
LogBase()
|
|
|
|
|
{
|
|
|
|
|
SetLogging(false);
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual const std::string& GetName() const = 0;
|
|
|
|
|
|
2015-05-28 17:28:34 +02:00
|
|
|
template<typename... Args> force_inline void Notice(const char* fmt, Args... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2015-02-02 10:14:49 +01:00
|
|
|
LogPrepare(LogNotice, fmt, fmt::do_unveil(args)...);
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2015-05-28 17:28:34 +02:00
|
|
|
template<typename... Args> force_inline void Log(const char* fmt, Args... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2014-08-22 23:15:02 +02:00
|
|
|
if (CheckLogging())
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
|
|
|
|
Notice(fmt, args...);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-28 17:28:34 +02:00
|
|
|
template<typename... Args> force_inline void Success(const char* fmt, Args... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2015-02-02 10:14:49 +01:00
|
|
|
LogPrepare(LogSuccess, fmt, fmt::do_unveil(args)...);
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2015-05-28 17:28:34 +02:00
|
|
|
template<typename... Args> force_inline void Warning(const char* fmt, Args... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2015-02-02 10:14:49 +01:00
|
|
|
LogPrepare(LogWarning, fmt, fmt::do_unveil(args)...);
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2015-05-28 17:28:34 +02:00
|
|
|
template<typename... Args> force_inline void Error(const char* fmt, Args... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2015-02-02 10:14:49 +01:00
|
|
|
LogPrepare(LogError, fmt, fmt::do_unveil(args)...);
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2015-05-28 17:28:34 +02:00
|
|
|
template<typename... Args> force_inline void Todo(const char* fmt, Args... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2015-02-02 10:14:49 +01:00
|
|
|
LogPrepare(LogTodo, fmt, fmt::do_unveil(args)...);
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
2014-09-08 16:56:47 +02:00
|
|
|
};
|