rpcsx/rpcs3/Emu/SysCalls/LogBase.h

75 lines
1.5 KiB
C
Raw Normal View History

#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,
LogTodo,
2014-08-23 16:51:51 +02:00
};
void LogOutput(LogType type, std::string text) const;
template<typename... Args> never_inline safe_buffers void LogPrepare(LogType type, const char* fmt, Args... args) const
{
2015-08-12 20:38:17 +02:00
LogOutput(type, fmt::format(fmt, args...));
}
2014-08-22 16:58:50 +02:00
never_inline safe_buffers void LogPrepare(LogType type, const char* fmt) const
{
LogOutput(type, fmt);
}
public:
2014-07-21 18:39:00 +02:00
void SetLogging(bool value)
{
2014-07-21 18:39:00 +02:00
m_logging = value;
}
2014-07-21 18:39:00 +02:00
LogBase()
{
SetLogging(false);
}
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
{
LogPrepare(LogNotice, fmt, fmt::do_unveil(args)...);
}
2015-05-28 17:28:34 +02:00
template<typename... Args> force_inline void Log(const char* fmt, Args... args) const
{
2014-08-22 23:15:02 +02:00
if (CheckLogging())
{
Notice(fmt, args...);
}
}
2015-05-28 17:28:34 +02:00
template<typename... Args> force_inline void Success(const char* fmt, Args... args) const
{
LogPrepare(LogSuccess, fmt, fmt::do_unveil(args)...);
}
2015-05-28 17:28:34 +02:00
template<typename... Args> force_inline void Warning(const char* fmt, Args... args) const
{
LogPrepare(LogWarning, fmt, fmt::do_unveil(args)...);
}
2015-05-28 17:28:34 +02:00
template<typename... Args> force_inline void Error(const char* fmt, Args... args) const
{
LogPrepare(LogError, fmt, fmt::do_unveil(args)...);
}
2015-05-28 17:28:34 +02:00
template<typename... Args> force_inline void Todo(const char* fmt, Args... args) const
{
LogPrepare(LogTodo, fmt, fmt::do_unveil(args)...);
}
2014-09-08 16:56:47 +02:00
};