rpcsx/rpcs3/Emu/SysCalls/LogBase.h

70 lines
1.4 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, const std::string& text) const;
template<typename... Args> never_inline void LogPrepare(LogType type, const char* fmt, Args... args) const
{
2015-03-07 14:39:07 +01:00
LogOutput(type, fmt::Format(fmt, args...));
}
2014-08-22 16:58:50 +02:00
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
};