30 #ifdef E3D_LOG_TO_FILE
31 static std::optional<std::unique_ptr<FILE, int(*)(FILE*)>> log_fp;
33 #ifdef E3D_TARGET_SWITCH
35 extern "C" void consoleUpdate(PrintConsole* console);
38 static bool debug_show =
false;
41 void Eng3D::Log::log(
const std::string_view severity,
const std::string_view category,
const std::string_view msg) {
42 if(!debug_show && severity ==
"DEBUG")
return;
43 #ifdef E3D_LOG_TO_FILE
44 if(!log_fp.has_value())
45 log_fp.emplace(std::unique_ptr<FILE,
int (*)(FILE *)>(fopen(
"log.txt",
"w+t"), fclose));
46 fprintf((*log_fp).get(),
"<%s:%s> %s\n", severity.data(), category.data(), msg.data());
48 # ifndef E3D_TARGET_SWITCH
49 printf(
"<%s:%s> %s\n", severity.data(), category.data(), msg.data());
52 snprintf(tmpbuf,
sizeof(tmpbuf),
"<%s:%s> %s", severity.c_str(), category.c_str(), msg.c_str());
53 fprintf(stderr, tmpbuf);
59 #if defined E3D_DEBUG || 1
void error(const std::string_view category, const std::string_view msg)
void debug(const std::string_view category, const std::string_view msg)
void log(const std::string_view severity, const std::string_view category, const std::string_view msg)
Logs data to a file or console.
void warning(const std::string_view category, const std::string_view msg)