Add PID to logfile

This avoid log corruption when multiple gBar instances are open at the same, as the logfile was the same
This commit is contained in:
scorpion-26 2023-09-01 03:17:58 +02:00
parent 9ecba84be5
commit 6f9da7f7c9

View file

@ -9,10 +9,11 @@ namespace Logging
void Init()
{
logFile = std::ofstream("/tmp/gBar.log");
pid_t pid = getpid();
logFile = std::ofstream("/tmp/gBar-" + std::to_string(pid) + ".log");
if (!logFile.is_open())
{
LOG("Cannot open logfile(/tmp/gBar.log)");
LOG("Cannot open logfile(/tmp/gBar-" << pid << ".log)");
}
}