mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
begenning the refactor
This commit is contained in:
135
runtime/Includes/Core/Logs.inl
git.filemode.normal_file
135
runtime/Includes/Core/Logs.inl
git.filemode.normal_file
@@ -0,0 +1,135 @@
|
||||
/* **************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Logs.inl :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/27 17:19:47 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/27 17:19:47 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* **************************************************************************** */
|
||||
|
||||
#include <Core/Logs.h>
|
||||
#include <Core/Format.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
template<typename... Args>
|
||||
void DebugLog(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
|
||||
{
|
||||
using namespace std::literals;
|
||||
try
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << Format(message, args...);
|
||||
Logs::Report(LogType::Debug, line, file, function, ss.str());
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
Logs::Report(LogType::Error, "formatter exception catched in the log printer : "s + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Error(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
|
||||
{
|
||||
using namespace std::literals;
|
||||
try
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << Format(message, args...);
|
||||
Logs::Report(LogType::Error, line, file, function, ss.str());
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
Logs::Report(LogType::Error, "formatter exception catched in the log printer : "s + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Warning(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
|
||||
{
|
||||
using namespace std::literals;
|
||||
try
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << Format(message, args...);
|
||||
Logs::Report(LogType::Warning, line, file, function, ss.str());
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
Logs::Report(LogType::Error, "formatter exception catched in the log printer : "s + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Message(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
|
||||
{
|
||||
using namespace std::literals;
|
||||
try
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << Format(message, args...);
|
||||
Logs::Report(LogType::Message, line, file, function, ss.str());
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
Logs::Report(LogType::Error, "formatter exception catched in the log printer : "s + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void FatalError(unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
|
||||
{
|
||||
using namespace std::literals;
|
||||
try
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << Format(message, args...);
|
||||
Logs::Report(LogType::FatalError, line, file, function, ss.str());
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
Logs::Report(LogType::Error, "formatter exception catched in the log printer : "s + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Verify(bool cond, unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
|
||||
{
|
||||
using namespace std::literals;
|
||||
if(cond)
|
||||
return;
|
||||
try
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << Format("Verification failed : %", message, args...);
|
||||
Logs::Report(LogType::FatalError, line, file, function, ss.str());
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
Logs::Report(LogType::Error, "formatter exception catched in the log printer : "s + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
template<typename... Args>
|
||||
void Assert(bool cond, unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
|
||||
{
|
||||
using namespace std::literals;
|
||||
if(cond)
|
||||
return;
|
||||
try
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << Format("Assertion failed : %", message, args...);
|
||||
Logs::Report(LogType::FatalError, line, file, function, ss.str());
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
Logs::Report(LogType::Error, "formatter exception catched in the log printer : "s + e.what());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user