fix: thread safe access to log file
This commit is contained in:
parent
f6321f8e54
commit
815ebbdefa
@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
#include "log_file.hpp"
|
#include "log_file.hpp"
|
||||||
#include "file_system.hpp"
|
#include "file_system.hpp"
|
||||||
#include "console.hpp"
|
|
||||||
|
std::mutex log_file::log_file_mutex;
|
||||||
|
|
||||||
const char* log_file::log_file_name;
|
const char* log_file::log_file_name;
|
||||||
|
|
||||||
@ -68,6 +69,8 @@ void log_file::com_log_print_message(const std::string& msg)
|
|||||||
|
|
||||||
void log_file::info(const std::string& msg)
|
void log_file::info(const std::string& msg)
|
||||||
{
|
{
|
||||||
|
std::lock_guard _(log_file_mutex);
|
||||||
|
|
||||||
if (com_logfile && com_logfile->current.integer)
|
if (com_logfile && com_logfile->current.integer)
|
||||||
{
|
{
|
||||||
com_log_print_message(msg);
|
com_log_print_message(msg);
|
||||||
|
@ -12,6 +12,7 @@ public:
|
|||||||
static const game::native::dvar_t* com_logfile;
|
static const game::native::dvar_t* com_logfile;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static std::mutex log_file_mutex;
|
||||||
static const char* log_file_name;
|
static const char* log_file_name;
|
||||||
|
|
||||||
static int opening_qconsole;
|
static int opening_qconsole;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user