Unverified Commit ad393b83 authored by Gabi Melman's avatar Gabi Melman Committed by GitHub

Revert 01dac453

parent 01dac453
...@@ -28,11 +28,10 @@ public: ...@@ -28,11 +28,10 @@ public:
std::vector<details::log_msg_buffer> last_raw(size_t lim = 0) std::vector<details::log_msg_buffer> last_raw(size_t lim = 0)
{ {
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_); std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
auto items_available = q_.size(); auto n_items = lim > 0 ? (std::min)(lim, q_.size()) : q_.size();
auto n_items = lim > 0 ? (std::min)(lim, items_available) : items_available;
std::vector<details::log_msg_buffer> ret; std::vector<details::log_msg_buffer> ret;
ret.reserve(n_items); ret.reserve(n_items);
for (size_t i = (items_available - n_items); i < items_available; i++) for (size_t i = 0; i < n_items; i++)
{ {
ret.push_back(q_.at(i)); ret.push_back(q_.at(i));
} }
...@@ -42,11 +41,10 @@ public: ...@@ -42,11 +41,10 @@ public:
std::vector<std::string> last_formatted(size_t lim = 0) std::vector<std::string> last_formatted(size_t lim = 0)
{ {
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_); std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
auto items_available = q_.size(); auto n_items = lim > 0 ? (std::min)(lim, q_.size()) : q_.size();
auto n_items = lim > 0 ? (std::min)(lim, items_available) : items_available;
std::vector<std::string> ret; std::vector<std::string> ret;
ret.reserve(n_items); ret.reserve(n_items);
for (size_t i = (items_available - n_items); i < items_available; i++) for (size_t i = 0; i < n_items; i++)
{ {
memory_buf_t formatted; memory_buf_t formatted;
base_sink<Mutex>::formatter_->format(q_.at(i), formatted); base_sink<Mutex>::formatter_->format(q_.at(i), formatted);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment