From bc55ed496f48f8b9f5ecde3d6dfc35d03912ba2e Mon Sep 17 00:00:00 2001 From: Aleksandr Popovich Date: Mon, 19 May 2025 21:29:22 +0000 Subject: add option to censor the username in logs (#111) Signed-off-by: Aleksandr Popovich Co-authored-by: Esther1024 Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/111 Co-authored-by: Aleksandr Popovich Co-committed-by: Aleksandr Popovich --- src/common/logging/backend.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/common/logging/backend.cpp') 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 #include #include +#include #include +#include #include #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(); } -- cgit v1.2.3