Commit f1718fb5 authored by gabime's avatar gabime

clang-format

parent 6b527a50
......@@ -17,31 +17,34 @@ struct log_msg_buffer : log_msg
fmt::basic_memory_buffer<char, 200> payload_buf;
log_msg_buffer() = default;
log_msg_buffer(const log_msg &orig_msg): log_msg(orig_msg)
log_msg_buffer(const log_msg &orig_msg)
: log_msg(orig_msg)
{
update_buffers();
}
log_msg_buffer(const log_msg_buffer& other):log_msg(other)
log_msg_buffer(const log_msg_buffer &other)
: log_msg(other)
{
update_buffers();
}
log_msg_buffer(const log_msg_buffer&& other):log_msg(std::move(other))
log_msg_buffer(const log_msg_buffer &&other)
: log_msg(std::move(other))
{
update_buffers();
}
log_msg_buffer& operator=(log_msg_buffer &other) SPDLOG_NOEXCEPT
log_msg_buffer &operator=(log_msg_buffer &other) SPDLOG_NOEXCEPT
{
*static_cast<log_msg*>(this) = other;
*static_cast<log_msg *>(this) = other;
update_buffers();
return *this;
}
log_msg_buffer& operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT
log_msg_buffer &operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT
{
*static_cast<log_msg*>(this) = std::move(other);
*static_cast<log_msg *>(this) = std::move(other);
update_buffers();
return *this;
}
......@@ -53,10 +56,10 @@ struct log_msg_buffer : log_msg
logger_name = string_view_t{loggername_buf.data(), loggername_buf.size()};
payload_buf.clear();
payload_buf.append(payload.data(),payload.data() + payload.size());
payload_buf.append(payload.data(), payload.data() + payload.size());
payload = string_view_t{payload_buf.data(), payload_buf.size()};
}
};
}
}
\ No newline at end of file
} // namespace details
} // namespace spdlog
\ No newline at end of file
......@@ -7,7 +7,6 @@
#include "spdlog/details/mpmc_blocking_q.h"
#include "spdlog/details/os.h"
#include <chrono>
#include <memory>
#include <thread>
......@@ -31,9 +30,9 @@ enum class async_msg_type
#include "spdlog/details/log_msg_buffer.h"
// Async msg to move to/from the queue
// Movable only. should never be copied
struct async_msg:log_msg_buffer
struct async_msg : log_msg_buffer
{
async_msg_type msg_type {async_msg_type::log};
async_msg_type msg_type{async_msg_type::log};
async_logger_ptr worker_ptr;
async_msg() = default;
......@@ -53,7 +52,7 @@ struct async_msg:log_msg_buffer
async_msg &operator=(async_msg &&other)
{
*static_cast<log_msg_buffer*>(this) = std::move(other);
*static_cast<log_msg_buffer *>(this) = std::move(other);
msg_type = other.msg_type;
worker_ptr = std::move(other.worker_ptr);
return *this;
......@@ -68,8 +67,7 @@ struct async_msg:log_msg_buffer
: log_msg_buffer(m)
, msg_type(the_type)
, worker_ptr(std::move(worker))
{
}
{}
async_msg(async_logger_ptr &&worker, async_msg_type the_type)
: log_msg_buffer()
......@@ -80,7 +78,6 @@ struct async_msg:log_msg_buffer
explicit async_msg(async_msg_type the_type)
: async_msg(nullptr, the_type)
{}
};
class thread_pool
......
......@@ -34,7 +34,6 @@
// l.warn("This will trigger the log of all prev messages in the queue");
// }
namespace spdlog {
namespace sinks {
template<typename Mutex>
......@@ -42,7 +41,8 @@ class backtrace_sink : public dist_sink<Mutex>
{
public:
explicit backtrace_sink(level::level_enum trigger_level = spdlog::level::warn, size_t n_messages = 32)
: trigger_level_{trigger_level}, traceback_msgs_{n_messages}
: trigger_level_{trigger_level}
, traceback_msgs_{n_messages}
{}
protected:
......@@ -54,40 +54,39 @@ protected:
// otherwise save the message in the queue for future trigger.
void sink_it_(const details::log_msg &msg) override
{
if(msg.level < trigger_level_)
if (msg.level < trigger_level_)
{
traceback_msgs_.push_back(details::log_msg_buffer(msg));
}
if(msg.level > level::debug)
if (msg.level > level::debug)
{
dist_sink<Mutex>::sink_it_(msg);
}
if(msg.level >= trigger_level_)
if (msg.level >= trigger_level_)
{
log_backtrace_(msg.logger_name);
}
}
void log_backtrace_(const string_view_t& logger_name)
void log_backtrace_(const string_view_t &logger_name)
{
if(traceback_msgs_.empty())
if (traceback_msgs_.empty())
{
return;
}
dist_sink<Mutex>::sink_it_(details::log_msg{
logger_name,level::info,"********************* [Backtrace Start] *********************"});
dist_sink<Mutex>::sink_it_(
details::log_msg{logger_name, level::info, "********************* [Backtrace Start] *********************"});
do
{
details::log_msg_buffer popped;
traceback_msgs_.pop_front(popped);
dist_sink<Mutex>::sink_it_(popped);
}
while (!traceback_msgs_.empty());
} while (!traceback_msgs_.empty());
dist_sink<Mutex>::sink_it_(details::log_msg{
logger_name,level::info,"********************* [Backtrace End] ***********************"});
dist_sink<Mutex>::sink_it_(
details::log_msg{logger_name, level::info, "********************* [Backtrace End] ***********************"});
}
};
......
......@@ -11,7 +11,6 @@
#include "spdlog/details/os.h"
#include "spdlog/details/synchronous_factory.h"
#include <chrono>
#include <cstdio>
#include <ctime>
......
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