diff options
| author | 2021-07-07 00:40:31 -0700 | |
|---|---|---|
| committer | 2021-07-07 00:40:31 -0700 | |
| commit | 2eb018c80fd2a83686ee11a80c7427a98ea44354 (patch) | |
| tree | a062eae0798d08a88411642490c2fef96b082dc6 /src/common/logging/backend.cpp | |
| parent | Merge pull request #6497 from FernandoS27/scotty-doesnt-know (diff) | |
| parent | common: logging: backend: Close the file after exceeding the write limit (diff) | |
| download | yuzu-2eb018c80fd2a83686ee11a80c7427a98ea44354.tar.gz yuzu-2eb018c80fd2a83686ee11a80c7427a98ea44354.tar.xz yuzu-2eb018c80fd2a83686ee11a80c7427a98ea44354.zip | |
Merge pull request #6562 from Morph1984/flush-behavior
common: fs: More misc. changes
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) { | |||
| 171 | FileBackend::~FileBackend() = default; | 171 | FileBackend::~FileBackend() = default; |
| 172 | 172 | ||
| 173 | void FileBackend::Write(const Entry& entry) { | 173 | void FileBackend::Write(const Entry& entry) { |
| 174 | if (!file->IsOpen()) { | ||
| 175 | return; | ||
| 176 | } | ||
| 177 | |||
| 174 | using namespace Common::Literals; | 178 | using namespace Common::Literals; |
| 175 | // prevent logs from going over the maximum size (in case its spamming and the user doesn't | 179 | // Prevent logs from exceeding a set maximum size in the event that log entries are spammed. |
| 176 | // know) | ||
| 177 | constexpr std::size_t MAX_BYTES_WRITTEN = 100_MiB; | 180 | constexpr std::size_t MAX_BYTES_WRITTEN = 100_MiB; |
| 178 | constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1_GiB; | 181 | constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1_GiB; |
| 179 | 182 | ||
| 180 | if (!file->IsOpen()) { | 183 | const bool write_limit_exceeded = |
| 181 | return; | 184 | bytes_written > MAX_BYTES_WRITTEN_EXTENDED || |
| 182 | } | 185 | (bytes_written > MAX_BYTES_WRITTEN && !Settings::values.extended_logging); |
| 183 | 186 | ||
| 184 | if (Settings::values.extended_logging && bytes_written > MAX_BYTES_WRITTEN_EXTENDED) { | 187 | // Close the file after the write limit is exceeded. |
| 185 | return; | 188 | if (write_limit_exceeded) { |
| 186 | } else if (!Settings::values.extended_logging && bytes_written > MAX_BYTES_WRITTEN) { | 189 | file->Close(); |
| 187 | return; | 190 | return; |
| 188 | } | 191 | } |
| 189 | 192 | ||