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,
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-08 16:56:47 +02:00
|
|
|
void LogOutput(LogType type, const char* info, const std::string& text) const;
|
|
|
|
|
void LogOutput(LogType type, const u32 id, const char* info, const std::string& text) const;
|
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;
|
|
|
|
|
|
2014-09-17 15:15:17 +02:00
|
|
|
template<typename... Targs> __noinline void Notice(const u32 id, const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2014-09-30 00:28:02 +02:00
|
|
|
LogOutput(LogNotice, id, " : ", fmt::Format(fmt, args...));
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-17 15:15:17 +02:00
|
|
|
template<typename... Targs> __noinline void Notice(const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2014-09-30 00:28:02 +02:00
|
|
|
LogOutput(LogNotice, " : ", fmt::Format(fmt, args...));
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-08 16:56:47 +02: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...);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-08 16:56:47 +02:00
|
|
|
template<typename... Targs> __forceinline void Log(const u32 id, 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(id, fmt, args...);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-17 15:15:17 +02:00
|
|
|
template<typename... Targs> __noinline void Success(const u32 id, const char* fmt, Targs... args) const
|
2014-08-23 16:51:51 +02:00
|
|
|
{
|
2014-09-30 00:28:02 +02:00
|
|
|
LogOutput(LogSuccess, id, " : ", fmt::Format(fmt, args...));
|
2014-08-23 16:51:51 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-17 15:15:17 +02:00
|
|
|
template<typename... Targs> __noinline void Success(const char* fmt, Targs... args) const
|
2014-08-23 16:51:51 +02:00
|
|
|
{
|
2014-09-30 00:28:02 +02:00
|
|
|
LogOutput(LogSuccess, " : ", fmt::Format(fmt, args...));
|
2014-08-23 16:51:51 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-17 15:15:17 +02:00
|
|
|
template<typename... Targs> __noinline void Warning(const u32 id, const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2014-08-23 16:51:51 +02:00
|
|
|
LogOutput(LogWarning, id, " warning: ", fmt::Format(fmt, args...));
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-17 15:15:17 +02:00
|
|
|
template<typename... Targs> __noinline void Warning(const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2014-08-23 16:51:51 +02:00
|
|
|
LogOutput(LogWarning, " warning: ", fmt::Format(fmt, args...));
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-17 15:15:17 +02:00
|
|
|
template<typename... Targs> __noinline void Error(const u32 id, const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2014-08-23 16:51:51 +02:00
|
|
|
LogOutput(LogError, id, " error: ", fmt::Format(fmt, args...));
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-17 15:15:17 +02:00
|
|
|
template<typename... Targs> __noinline void Error(const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2014-08-23 16:51:51 +02:00
|
|
|
LogOutput(LogError, " error: ", fmt::Format(fmt, args...));
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-17 15:15:17 +02:00
|
|
|
template<typename... Targs> __noinline void Todo(const u32 id, const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2014-08-23 16:51:51 +02:00
|
|
|
LogOutput(LogError, id, " TODO: ", fmt::Format(fmt, args...));
|
2014-07-21 17:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-17 15:15:17 +02:00
|
|
|
template<typename... Targs> __noinline void Todo(const char* fmt, Targs... args) const
|
2014-07-21 17:58:03 +02:00
|
|
|
{
|
2014-08-23 16:51:51 +02:00
|
|
|
LogOutput(LogError, " TODO: ", fmt::Format(fmt, 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);
|
|
|
|
|
};
|
|
|
|
|
}
|