summaryrefslogtreecommitdiffstats
path: root/src/common/logging
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-07-07 09:40:31 +0200
committerGitHub <noreply@github.com>2021-07-07 09:40:31 +0200
commit2eb018c80fd2a83686ee11a80c7427a98ea44354 (patch)
treea062eae0798d08a88411642490c2fef96b082dc6 /src/common/logging
parentMerge pull request #6497 from FernandoS27/scotty-doesnt-know (diff)
parentcommon: logging: backend: Close the file after exceeding the write limit (diff)
downloadyuzu-2eb018c80fd2a83686ee11a80c7427a98ea44354.tar
yuzu-2eb018c80fd2a83686ee11a80c7427a98ea44354.tar.gz
yuzu-2eb018c80fd2a83686ee11a80c7427a98ea44354.tar.bz2
yuzu-2eb018c80fd2a83686ee11a80c7427a98ea44354.tar.lz
yuzu-2eb018c80fd2a83686ee11a80c7427a98ea44354.tar.xz
yuzu-2eb018c80fd2a83686ee11a80c7427a98ea44354.tar.zst
yuzu-2eb018c80fd2a83686ee11a80c7427a98ea44354.zip
Diffstat (limited to 'src/common/logging')
-rw-r--r--src/common/logging/backend.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index b6fa4affb..61dddab3f 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -171,19 +171,22 @@ FileBackend::FileBackend(const std::filesystem::path& filename) {
FileBackend::~FileBackend() = default;
void FileBackend::Write(const Entry& entry) {
+ if (!file->IsOpen()) {
+ return;
+ }
+
using namespace Common::Literals;
- // prevent logs from going over the maximum size (in case its spamming and the user doesn't
- // know)
+ // Prevent logs from exceeding a set maximum size in the event that log entries are spammed.
constexpr std::size_t MAX_BYTES_WRITTEN = 100_MiB;
constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1_GiB;
- if (!file->IsOpen()) {
- return;
- }
+ const bool write_limit_exceeded =
+ bytes_written > MAX_BYTES_WRITTEN_EXTENDED ||
+ (bytes_written > MAX_BYTES_WRITTEN && !Settings::values.extended_logging);
- if (Settings::values.extended_logging && bytes_written > MAX_BYTES_WRITTEN_EXTENDED) {
- return;
- } else if (!Settings::values.extended_logging && bytes_written > MAX_BYTES_WRITTEN) {
+ // Close the file after the write limit is exceeded.
+ if (write_limit_exceeded) {
+ file->Close();
return;
}