2017-01-20 08:36:52 -05:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
class Logger : public Component
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Logger();
|
|
|
|
~Logger();
|
2022-06-12 17:07:53 -04:00
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
static bool IsConsoleReady();
|
|
|
|
|
2022-07-22 05:27:38 -04:00
|
|
|
static void Print_Stub(int channel, const char* message, ...);
|
2017-01-19 16:23:59 -05:00
|
|
|
|
2018-12-17 08:29:18 -05:00
|
|
|
static void PipeOutput(void(*callback)(const std::string&));
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
static void Flush();
|
|
|
|
|
2022-06-12 17:07:53 -04:00
|
|
|
static void PrintInternal(int channel, std::string_view fmt, std::format_args&& args);
|
|
|
|
static void ErrorInternal(Game::errorParm_t error, std::string_view fmt, std::format_args&& args);
|
|
|
|
static void PrintErrorInternal(int channel, std::string_view fmt, std::format_args&& args);
|
|
|
|
static void WarningInternal(int channel, std::string_view fmt, std::format_args&& args);
|
2022-06-22 04:58:51 -04:00
|
|
|
static void DebugInternal(std::string_view fmt, std::format_args&& args, const std::source_location& loc);
|
2022-06-12 17:07:53 -04:00
|
|
|
|
2022-06-22 04:58:51 -04:00
|
|
|
static void Print(std::string_view fmt)
|
2022-06-12 17:07:53 -04:00
|
|
|
{
|
|
|
|
PrintInternal(Game::CON_CHANNEL_DONT_FILTER, fmt, std::make_format_args(0));
|
|
|
|
}
|
|
|
|
|
2022-06-22 04:58:51 -04:00
|
|
|
static void Print(int channel, std::string_view fmt)
|
2022-06-12 17:07:53 -04:00
|
|
|
{
|
|
|
|
PrintInternal(channel, fmt, std::make_format_args(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Args>
|
2022-06-22 04:58:51 -04:00
|
|
|
static void Print(std::string_view fmt, Args&&... args)
|
2022-06-12 17:07:53 -04:00
|
|
|
{
|
|
|
|
PrintInternal(Game::CON_CHANNEL_DONT_FILTER, fmt, std::make_format_args(args...));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Args>
|
2022-06-22 04:58:51 -04:00
|
|
|
static void Print(int channel, std::string_view fmt, Args&&... args)
|
2022-06-12 17:07:53 -04:00
|
|
|
{
|
|
|
|
PrintInternal(channel, fmt, std::make_format_args(args...));
|
|
|
|
}
|
|
|
|
|
2022-06-22 04:58:51 -04:00
|
|
|
static void Error(Game::errorParm_t error, std::string_view fmt)
|
2022-06-12 17:07:53 -04:00
|
|
|
{
|
|
|
|
ErrorInternal(error, fmt, std::make_format_args(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Args>
|
2022-06-22 04:58:51 -04:00
|
|
|
static void Error(Game::errorParm_t error, std::string_view fmt, Args&&... args)
|
2022-06-12 17:07:53 -04:00
|
|
|
{
|
|
|
|
ErrorInternal(error, fmt, std::make_format_args(args...));
|
|
|
|
}
|
|
|
|
|
2022-06-22 04:58:51 -04:00
|
|
|
static void Warning(int channel, std::string_view fmt)
|
2022-06-12 17:07:53 -04:00
|
|
|
{
|
|
|
|
WarningInternal(channel, fmt, std::make_format_args(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Args>
|
2022-06-22 04:58:51 -04:00
|
|
|
static void Warning(int channel, std::string_view fmt, Args&&... args)
|
2022-06-12 17:07:53 -04:00
|
|
|
{
|
|
|
|
WarningInternal(channel, fmt, std::make_format_args(args...));
|
|
|
|
}
|
|
|
|
|
2022-06-22 04:58:51 -04:00
|
|
|
static void PrintError(int channel, std::string_view fmt)
|
2022-06-12 17:07:53 -04:00
|
|
|
{
|
|
|
|
PrintErrorInternal(channel, fmt, std::make_format_args(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Args>
|
2022-06-22 04:58:51 -04:00
|
|
|
static void PrintError(int channel, std::string_view fmt, Args&&... args)
|
2022-06-12 17:07:53 -04:00
|
|
|
{
|
|
|
|
PrintErrorInternal(channel, fmt, std::make_format_args(args...));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Args>
|
2022-06-22 04:58:51 -04:00
|
|
|
class Debug
|
2022-06-12 17:07:53 -04:00
|
|
|
{
|
2022-06-22 04:58:51 -04:00
|
|
|
public:
|
|
|
|
Debug([[maybe_unused]] std::string_view fmt, [[maybe_unused]] const Args&... args, [[maybe_unused]] const std::source_location& loc = std::source_location::current())
|
|
|
|
{
|
|
|
|
#ifdef _DEBUG
|
|
|
|
DebugInternal(fmt, std::make_format_args(args...), loc);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
};
|
2022-06-12 17:07:53 -04:00
|
|
|
|
|
|
|
template <typename... Args>
|
2022-06-22 04:58:51 -04:00
|
|
|
Debug(std::string_view fmt, const Args&... args) -> Debug<Args...>;
|
2022-06-12 17:07:53 -04:00
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
private:
|
|
|
|
static std::mutex MessageMutex;
|
|
|
|
static std::vector<std::string> MessageQueue;
|
|
|
|
static std::vector<Network::Address> LoggingAddresses[2];
|
2018-12-17 08:29:18 -05:00
|
|
|
static void(*PipeCallback)(const std::string&);
|
2017-01-19 16:23:59 -05:00
|
|
|
|
2022-07-04 15:09:26 -04:00
|
|
|
static void MessagePrint(int channel, const std::string& msg);
|
2017-01-19 16:23:59 -05:00
|
|
|
static void Frame();
|
2022-07-22 05:27:38 -04:00
|
|
|
static void G_LogPrintf_Hk(const char* fmt, ...);
|
|
|
|
static void PrintMessage_Stub();
|
2017-01-19 16:23:59 -05:00
|
|
|
static void PrintMessagePipe(const char* data);
|
2018-12-17 08:29:18 -05:00
|
|
|
static void EnqueueMessage(const std::string& message);
|
2017-01-19 16:23:59 -05:00
|
|
|
|
2022-07-22 05:27:38 -04:00
|
|
|
static void BuildOSPath_Stub();
|
2017-02-24 19:17:11 -05:00
|
|
|
static void RedirectOSPath(const char* file, char* folder);
|
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
static void NetworkLog(const char* data, bool gLog);
|
2022-06-16 10:15:26 -04:00
|
|
|
|
|
|
|
static void AddServerCommands();
|
2017-01-19 16:23:59 -05:00
|
|
|
};
|
|
|
|
}
|