diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2021-07-05 18:54:06 +0200 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2021-07-06 11:59:47 +0200 |
commit | a59ae5e702a9fed1626e8815b2208acc7f373e22 (patch) | |
tree | df07beed1c8a0d1ccd82ec9b42c54007c6a199ac /src | |
parent | common: fs: file: Revert Flush to its previous behavior and add Commit (diff) | |
download | yuzu-a59ae5e702a9fed1626e8815b2208acc7f373e22.tar yuzu-a59ae5e702a9fed1626e8815b2208acc7f373e22.tar.gz yuzu-a59ae5e702a9fed1626e8815b2208acc7f373e22.tar.bz2 yuzu-a59ae5e702a9fed1626e8815b2208acc7f373e22.tar.lz yuzu-a59ae5e702a9fed1626e8815b2208acc7f373e22.tar.xz yuzu-a59ae5e702a9fed1626e8815b2208acc7f373e22.tar.zst yuzu-a59ae5e702a9fed1626e8815b2208acc7f373e22.zip |
Diffstat (limited to '')
-rw-r--r-- | src/common/logging/backend.cpp | 19 |
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; } |