45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "LuaStateHandler.hpp"
|
|
#include "Types.hpp"
|
|
|
|
#define TSE_LOG(msg) TSE::Debug::Log(msg)
|
|
#define TSE_ERROR(msg) TSE::Debug::Error(msg)
|
|
#define TSE_WARNING(msg) TSE::Debug::Warning(msg)
|
|
|
|
namespace TSE
|
|
{
|
|
enum LogEntryType
|
|
{
|
|
Log,
|
|
Error,
|
|
Warning,
|
|
};
|
|
|
|
class Debug
|
|
{
|
|
public:
|
|
/// @brief initializes the log file in app data or .local, and binds lua functions
|
|
static void Init();
|
|
/// @brief logs soumething to the stdout, and into the log file
|
|
/// @param msg the message to be logged
|
|
static void Log(string msg);
|
|
/// @brief logs soumething to the stdout, and into the log file
|
|
/// @param msg the message to be logged
|
|
static void Error(string msg);
|
|
/// @brief logs soumething to the stdout, and into the log file
|
|
/// @param msg the message to be logged
|
|
static void Warning(string msg);
|
|
/// @brief closes the log file
|
|
static void Close();
|
|
static void AddCallback(void(*func)(const std::string&, const LogEntryType&));
|
|
|
|
private:
|
|
static std::ofstream logFile;
|
|
static std::vector<void(*)(const std::string&, const LogEntryType&)> onLogCallbacks;
|
|
};
|
|
|
|
} // namespace TSE
|
|
|
|
|