2012-11-15 00:39:56 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
class LogWriter
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
rFile m_logfile;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2014-04-08 19:29:17 +02:00
|
|
|
void WriteToLog(const std::string& prefix, const std::string& value, u8 lvl);
|
2012-11-15 00:39:56 +01:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
LogWriter();
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
template <typename ...Arg>
|
2014-06-08 16:52:35 +02:00
|
|
|
void Write(const std::string &fmt, Arg... args)
|
2014-04-01 02:33:55 +02:00
|
|
|
{
|
|
|
|
|
std::string frmt = fmt::Format(fmt, std::forward<Arg>(args)...);
|
|
|
|
|
WriteToLog("!", frmt, 2);
|
|
|
|
|
}
|
2014-06-08 16:52:35 +02:00
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
template <typename ...Arg>
|
2014-06-08 16:52:35 +02:00
|
|
|
void Error(const std::string &fmt, Arg... args)
|
2014-04-01 02:33:55 +02:00
|
|
|
{
|
|
|
|
|
std::string frmt = fmt::Format(fmt, std::forward<Arg>(args)...);
|
|
|
|
|
WriteToLog("E", frmt, 4);
|
|
|
|
|
}
|
2014-06-08 16:52:35 +02:00
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
template <typename ...Arg>
|
2014-06-08 16:52:35 +02:00
|
|
|
void Warning(const std::string &fmt, Arg... args)
|
2014-04-01 02:33:55 +02:00
|
|
|
{
|
|
|
|
|
std::string frmt = fmt::Format(fmt, std::forward<Arg>(args)...);
|
|
|
|
|
WriteToLog("W", frmt, 3);
|
|
|
|
|
}
|
2014-06-08 16:52:35 +02:00
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
template <typename ...Arg>
|
2014-06-08 16:52:35 +02:00
|
|
|
void Success(const std::string &fmt, Arg... args)
|
2014-04-01 02:33:55 +02:00
|
|
|
{
|
|
|
|
|
std::string frmt = fmt::Format(fmt, std::forward<Arg>(args)...);
|
|
|
|
|
WriteToLog("S", frmt, 1);
|
|
|
|
|
}
|
2014-05-02 08:30:32 +02:00
|
|
|
|
|
|
|
|
virtual void SkipLn();
|
2012-11-15 00:39:56 +01:00
|
|
|
};
|
|
|
|
|
|
2014-05-02 08:30:32 +02:00
|
|
|
|
2012-11-15 00:39:56 +01:00
|
|
|
extern LogWriter ConLog;
|