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;
|
|
|
|
|
|
|
|
|
|
template<typename... Targs>
|
|
|
|
|
__noinline void LogPrepare(LogType type, const char* fmt, size_t len, Targs... args) const
|
|
|
|
|
{
|
|
|
|
|
LogOutput(type, fmt::detail::format(fmt, len, args...));
|
|
|
|
|
}
|
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-01-18 23:54:56 +01:00
|
|
|
template<typename... Targs>
|
|
|
|
|
__forceinline void Notice(const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2015-01-18 23:54:56 +01:00
|
|
|
LogPrepare(LogNotice, fmt, strlen(fmt), fmt::do_unveil(args)...);
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2015-01-18 23:54:56 +01:00
|
|
|
template<typename... Targs>
|
|
|
|
|
__forceinline void Log(const char* fmt, Targs... 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-01-18 23:54:56 +01:00
|
|
|
template<typename... Targs>
|
|
|
|
|
__forceinline void Success(const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2015-01-18 23:54:56 +01:00
|
|
|
LogPrepare(LogSuccess, fmt, strlen(fmt), fmt::do_unveil(args)...);
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2015-01-18 23:54:56 +01:00
|
|
|
template<typename... Targs>
|
|
|
|
|
__forceinline void Warning(const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2015-01-18 23:54:56 +01:00
|
|
|
LogPrepare(LogWarning, fmt, strlen(fmt), fmt::do_unveil(args)...);
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2015-01-18 23:54:56 +01:00
|
|
|
template<typename... Targs>
|
|
|
|
|
__forceinline void Error(const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2015-01-18 23:54:56 +01:00
|
|
|
LogPrepare(LogError, fmt, strlen(fmt), fmt::do_unveil(args)...);
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2015-01-18 23:54:56 +01:00
|
|
|
template<typename... Targs>
|
|
|
|
|
__forceinline void Todo(const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2015-01-18 23:54:56 +01:00
|
|
|
LogPrepare(LogTodo, fmt, strlen(fmt), fmt::do_unveil(args)...);
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
2014-09-08 16:56:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
namespace hle
|
|
|
|
|
{
|
|
|
|
|
struct error
|
|
|
|
|
{
|
|
|
|
|
const s32 code;
|
|
|
|
|
const LogBase* const base;
|
|
|
|
|
const std::string text;
|
|
|
|
|
|
|
|
|
|
error(s32 errorCode, const char* errorText = nullptr);
|
|
|
|
|
error(s32 errorCode, const LogBase& base, const char* errorText = nullptr);
|
|
|
|
|
error(s32 errorCode, const LogBase* base, const char* errorText = nullptr);
|
|
|
|
|
|
|
|
|
|
void print(const char* func = nullptr);
|
|
|
|
|
};
|
|
|
|
|
}
|