Fix logging Log sometimes being overwritten on shutdown

This commit is contained in:
LightCat 2019-03-30 12:35:34 +01:00
parent 69b0a6550a
commit 6d033a5098

View File

@ -17,6 +17,7 @@
static settings::Bool log_to_console{ "hack.log-console", "false" }; static settings::Bool log_to_console{ "hack.log-console", "false" };
static bool shut_down = false;
FILE *logging::handle{ nullptr }; FILE *logging::handle{ nullptr };
#if ENABLE_LOGGING #if ENABLE_LOGGING
@ -31,6 +32,8 @@ void logging::Initialize()
void logging::Info(const char *fmt, ...) void logging::Info(const char *fmt, ...)
{ {
#if ENABLE_LOGGING #if ENABLE_LOGGING
if (shut_down)
return;
if (logging::handle == nullptr) if (logging::handle == nullptr)
logging::Initialize(); logging::Initialize();
@ -72,5 +75,6 @@ void logging::Shutdown()
#if ENABLE_LOGGING #if ENABLE_LOGGING
fclose(logging::handle); fclose(logging::handle);
logging::handle = nullptr; logging::handle = nullptr;
shut_down = true;
#endif #endif
} }