diff options
author | Wunkolo <Wunkolo@gmail.com> | 2021-06-23 14:18:27 -0700 |
---|---|---|
committer | Wunkolo <Wunkolo@gmail.com> | 2021-06-24 09:27:40 -0700 |
commit | 4569f39c7c1e3d7ce010f0b120e1f45dbba17b1c (patch) | |
tree | 591792bc47e26bc812e753b0891aab94a8a88352 /src/common/logging/backend.cpp | |
parent | 809e5fd52317f0a925ca463eca85a0b67d744f9e (diff) |
common: Replace common_sizes into user-literals
Removes common_sizes.h in favor of having `_KiB`, `_MiB`, `_GiB`, etc
user-literals within literals.h.
To keep the global namespace clean, users will have to use:
```
using namespace Common::Literals;
```
to access these literals.
Diffstat (limited to 'src/common/logging/backend.cpp')
-rw-r--r-- | src/common/logging/backend.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 47ce064784..b6fa4affb8 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -19,6 +19,8 @@ #include "common/assert.h" #include "common/fs/file.h" #include "common/fs/fs.h" +#include "common/literals.h" + #include "common/logging/backend.h" #include "common/logging/log.h" #include "common/logging/text_formatter.h" @@ -98,8 +100,8 @@ private: write_logs(entry); } - // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a case - // where a system is repeatedly spamming logs even on close. + // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a + // case where a system is repeatedly spamming logs even on close. const int MAX_LOGS_TO_WRITE = filter.IsDebug() ? INT_MAX : 100; int logs_written = 0; while (logs_written++ < MAX_LOGS_TO_WRITE && message_queue.Pop(entry)) { @@ -169,10 +171,11 @@ FileBackend::FileBackend(const std::filesystem::path& filename) { FileBackend::~FileBackend() = default; void FileBackend::Write(const Entry& entry) { + using namespace Common::Literals; // prevent logs from going over the maximum size (in case its spamming and the user doesn't // know) - constexpr std::size_t MAX_BYTES_WRITTEN = 100 * 1024 * 1024; - constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1024 * 1024 * 1024; + constexpr std::size_t MAX_BYTES_WRITTEN = 100_MiB; + constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1_GiB; if (!file->IsOpen()) { return; |