aboutsummaryrefslogtreecommitdiff
path: root/src/common/logging/backend.cpp
diff options
context:
space:
mode:
authorAleksandr Popovich <alekpopo@pm.me>2025-05-19 21:29:22 +0000
committerAlekPop <alekpop@noreply.localhost>2025-05-19 21:29:22 +0000
commitbc55ed496f48f8b9f5ecde3d6dfc35d03912ba2e (patch)
treed2f386813493254cca8c4d4887ba40fc9f82fdaa /src/common/logging/backend.cpp
parent244c07c999c509d05efd2ef9c56af3892f79d079 (diff)
add option to censor the username in logs (#111)
Signed-off-by: Aleksandr Popovich <alekpopo@pm.me> Co-authored-by: Esther1024 <danishreyjavik@outlook.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/111 Co-authored-by: Aleksandr Popovich <alekpopo@pm.me> Co-committed-by: Aleksandr Popovich <alekpopo@pm.me>
Diffstat (limited to 'src/common/logging/backend.cpp')
-rw-r--r--src/common/logging/backend.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index e5bf6b723a..ff07ab68eb 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -4,8 +4,10 @@
#include <atomic>
#include <chrono>
#include <climits>
+#include <regex>
#include <thread>
+#include <boost/algorithm/string/replace.hpp>
#include <fmt/ranges.h>
#ifdef _WIN32
@@ -104,9 +106,21 @@ public:
return;
}
- bytes_written += file->WriteString(FormatLogMessage(entry).append(1, '\n'));
+ auto message = FormatLogMessage(entry).append(1, '\n');
- // Option to log each line rather than 4k buffers
+#ifndef ANDROID
+ if (Settings::values.censor_username.GetValue()) {
+ char* username = getenv("USER");
+ if (!username) {
+ username = getenv("USERNAME");
+ }
+ boost::replace_all(message, username, "user");
+ }
+#endif
+
+ bytes_written += file->WriteString(message);
+
+ // Option to log each line rather than 4k buffers
if (Settings::values.log_flush_lines.GetValue()) {
file->Flush();
}