clang-format

This commit is contained in:
gabime
2019-08-27 20:22:07 +03:00
parent c55336e78d
commit c97c025adb
11 changed files with 82 additions and 88 deletions

View File

@@ -18,7 +18,8 @@ namespace sinks {
template<class Mutex>
class test_sink : public base_sink<Mutex>
{
const size_t lines_to_save = 100;
const size_t lines_to_save = 100;
public:
size_t msg_counter()
{
@@ -34,42 +35,41 @@ public:
void set_delay(std::chrono::milliseconds delay)
{
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
delay_ = delay;
}
// return last output without the eol
std::vector<std::string> lines()
{
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
return lines_;
}
// return last output without the eol
std::vector<std::string> lines()
{
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
return lines_;
}
protected:
void sink_it_(const details::log_msg &msg) override
{
fmt::memory_buffer formatted;
base_sink<Mutex>::formatter_->format(msg, formatted);
// save the line without the eol
auto eol_len = strlen(details::os::default_eol);
if(lines_.size() < lines_to_save)
{
lines_.emplace_back(formatted.begin(), formatted.end()-eol_len);
}
msg_counter_++;
std::this_thread::sleep_for(delay_);
{
fmt::memory_buffer formatted;
base_sink<Mutex>::formatter_->format(msg, formatted);
// save the line without the eol
auto eol_len = strlen(details::os::default_eol);
if (lines_.size() < lines_to_save)
{
lines_.emplace_back(formatted.begin(), formatted.end() - eol_len);
}
msg_counter_++;
std::this_thread::sleep_for(delay_);
}
void flush_() override
{
flush_counter_++;
}
size_t msg_counter_{0};
size_t flush_counter_{0};
std::chrono::milliseconds delay_{std::chrono::milliseconds::zero()};
std::vector<std::string> lines_;
std::vector<std::string> lines_;
};
using test_sink_mt = test_sink<std::mutex>;