diff options
| author | levlam <levlam@telegram.org> | 2021-05-17 16:18:19 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2021-05-17 16:18:19 +0300 |
| commit | 13a21b4fe2597a48ba6fd593b9080e4d93579ca1 (patch) | |
| tree | cc7b8a81ef00f786725f6cd39a44be22cf1d2750 /tdutils/td/utils/MemoryLog.h | |
| parent | a6a4eb6616ba1a21e200922290012c50818ca1f9 (diff) | |
Make LogInterface::append non-virtual.
Diffstat (limited to 'tdutils/td/utils/MemoryLog.h')
| -rw-r--r-- | tdutils/td/utils/MemoryLog.h | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/tdutils/td/utils/MemoryLog.h b/tdutils/td/utils/MemoryLog.h index 0e1e34b19..06bc2508c 100644 --- a/tdutils/td/utils/MemoryLog.h +++ b/tdutils/td/utils/MemoryLog.h @@ -28,7 +28,16 @@ class MemoryLog : public LogInterface { std::memset(buffer_, ' ', sizeof(buffer_)); } - void append(CSlice new_slice, int log_level) override { + Slice get_buffer() const { + return Slice(buffer_, sizeof(buffer_)); + } + + size_t get_pos() const { + return pos_ & (buffer_size - 1); + } + + private: + void do_append(int log_level, CSlice new_slice) final { Slice slice = new_slice; slice.truncate(MAX_OUTPUT_SIZE); while (!slice.empty() && slice.back() == '\n') { @@ -61,21 +70,8 @@ class MemoryLog : public LogInterface { size_t printed = std::snprintf(&buffer_[start_pos + 1], MAGIC_SIZE - 1, "LOG:%08x: ", real_pos); CHECK(printed == MAGIC_SIZE - 2); buffer_[start_pos + MAGIC_SIZE - 1] = ' '; - - if (log_level == VERBOSITY_NAME(FATAL)) { - process_fatal_error(new_slice); - } - } - - Slice get_buffer() const { - return Slice(buffer_, sizeof(buffer_)); } - size_t get_pos() const { - return pos_ & (buffer_size - 1); - } - - private: char buffer_[buffer_size]; std::atomic<uint32> pos_{0}; }; |
