summaryrefslogtreecommitdiff
path: root/src/common/logging
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/logging')
-rw-r--r--src/common/logging/backend.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 47ce06478..b6fa4affb 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -19,6 +19,8 @@
19#include "common/assert.h" 19#include "common/assert.h"
20#include "common/fs/file.h" 20#include "common/fs/file.h"
21#include "common/fs/fs.h" 21#include "common/fs/fs.h"
22#include "common/literals.h"
23
22#include "common/logging/backend.h" 24#include "common/logging/backend.h"
23#include "common/logging/log.h" 25#include "common/logging/log.h"
24#include "common/logging/text_formatter.h" 26#include "common/logging/text_formatter.h"
@@ -98,8 +100,8 @@ private:
98 write_logs(entry); 100 write_logs(entry);
99 } 101 }
100 102
101 // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a case 103 // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a
102 // where a system is repeatedly spamming logs even on close. 104 // case where a system is repeatedly spamming logs even on close.
103 const int MAX_LOGS_TO_WRITE = filter.IsDebug() ? INT_MAX : 100; 105 const int MAX_LOGS_TO_WRITE = filter.IsDebug() ? INT_MAX : 100;
104 int logs_written = 0; 106 int logs_written = 0;
105 while (logs_written++ < MAX_LOGS_TO_WRITE && message_queue.Pop(entry)) { 107 while (logs_written++ < MAX_LOGS_TO_WRITE && message_queue.Pop(entry)) {
@@ -169,10 +171,11 @@ FileBackend::FileBackend(const std::filesystem::path& filename) {
169FileBackend::~FileBackend() = default; 171FileBackend::~FileBackend() = default;
170 172
171void FileBackend::Write(const Entry& entry) { 173void FileBackend::Write(const Entry& entry) {
174 using namespace Common::Literals;
172 // prevent logs from going over the maximum size (in case its spamming and the user doesn't 175 // prevent logs from going over the maximum size (in case its spamming and the user doesn't
173 // know) 176 // know)
174 constexpr std::size_t MAX_BYTES_WRITTEN = 100 * 1024 * 1024; 177 constexpr std::size_t MAX_BYTES_WRITTEN = 100_MiB;
175 constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1024 * 1024 * 1024; 178 constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1_GiB;
176 179
177 if (!file->IsOpen()) { 180 if (!file->IsOpen()) {
178 return; 181 return;