summaryrefslogtreecommitdiff
path: root/src/common/logging
diff options
context:
space:
mode:
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) {
171FileBackend::~FileBackend() = default; 171FileBackend::~FileBackend() = default;
172 172
173void FileBackend::Write(const Entry& entry) { 173void 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