logging
This commit is contained in:
1 parent
f75369f670
commit
8388fd5d99
12 files changed
+97
-29
No files matched your search
+45
@@ -0,0 +1,45 @@
|
||||
#include "log.h"
|
||||
|
||||
inline std::ofstream logFile;
|
||||
|
||||
static void _log_write(const std::string& string)
|
||||
{
|
||||
std::println("{}", string);
|
||||
|
||||
if (logFile.is_open())
|
||||
{
|
||||
logFile << string << '\n';
|
||||
logFile.flush();
|
||||
}
|
||||
}
|
||||
|
||||
void log_init(const std::string& file)
|
||||
{
|
||||
logFile.open(file, std::ios::out | std::ios::trunc);
|
||||
if (!logFile) std::println("{}", std::format(LOG_INIT_ERROR, file));
|
||||
}
|
||||
|
||||
void log_error(const std::string& error)
|
||||
{
|
||||
_log_write(LOG_ERROR_FORMAT + error);
|
||||
}
|
||||
|
||||
void log_info(const std::string& info)
|
||||
{
|
||||
_log_write(LOG_INFO_FORMAT + info);
|
||||
}
|
||||
|
||||
void log_warning(const std::string& warning)
|
||||
{
|
||||
_log_write(LOG_WARNING_FORMAT + warning);
|
||||
}
|
||||
|
||||
void log_imgui(const std::string& imgui)
|
||||
{
|
||||
_log_write(LOG_IMGUI_FORMAT + imgui);
|
||||
}
|
||||
|
||||
void log_free(void)
|
||||
{
|
||||
logFile.close();
|
||||
}
|
||||
Reference in new issue
Block a user