From 6f9da7f7c953d4ea25868e34a6a74ec80a9911cd Mon Sep 17 00:00:00 2001 From: scorpion-26 Date: Fri, 1 Sep 2023 03:17:58 +0200 Subject: [PATCH] Add PID to logfile This avoid log corruption when multiple gBar instances are open at the same, as the logfile was the same --- src/Log.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Log.cpp b/src/Log.cpp index 63bd6df..31ddc16 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -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)"); } }