#pragma once #include #include namespace mlx { template 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 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 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 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 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 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 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 }