reformat code

This commit is contained in:
gabime 2023-09-25 16:20:42 +03:00
parent cafde8ccc1
commit 4b2a8219d5
27 changed files with 123 additions and 120 deletions

View File

@ -41,9 +41,9 @@ public:
It end,
std::weak_ptr<details::thread_pool> tp,
async_overflow_policy overflow_policy = async_overflow_policy::block)
: logger(std::move(logger_name), begin, end)
, thread_pool_(std::move(tp))
, overflow_policy_(overflow_policy) {}
: logger(std::move(logger_name), begin, end),
thread_pool_(std::move(tp)),
overflow_policy_(overflow_policy) {}
async_logger(std::string logger_name,
sinks_init_list sinks_list,

View File

@ -306,9 +306,9 @@ private:
struct source_loc {
SPDLOG_CONSTEXPR source_loc() = default;
SPDLOG_CONSTEXPR source_loc(const char *filename_in, int line_in, const char *funcname_in)
: filename{filename_in}
, line{line_in}
, funcname{funcname_in} {}
: filename{filename_in},
line{line_in},
funcname{funcname_in} {}
SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT { return line == 0; }
const char *filename{nullptr};
@ -318,10 +318,10 @@ struct source_loc {
struct file_event_handlers {
file_event_handlers()
: before_open(nullptr)
, after_open(nullptr)
, before_close(nullptr)
, after_close(nullptr) {}
: before_open(nullptr),
after_open(nullptr),
before_close(nullptr),
after_close(nullptr) {}
std::function<void(const filename_t &filename)> before_open;
std::function<void(const filename_t &filename, std::FILE *file_stream)> after_open;

View File

@ -25,7 +25,8 @@ public:
explicit circular_q(size_t max_items)
: max_items_(max_items + 1) // one item is reserved as marker for full q
, v_(max_items_) {}
,
v_(max_items_) {}
circular_q(const circular_q &) = default;
circular_q &operator=(const circular_q &) = default;

View File

@ -17,14 +17,16 @@ SPDLOG_INLINE log_msg::log_msg(spdlog::log_clock::time_point log_time,
string_view_t a_logger_name,
spdlog::level::level_enum lvl,
spdlog::string_view_t msg)
: logger_name(a_logger_name)
, level(lvl)
, time(log_time)
: logger_name(a_logger_name),
level(lvl),
time(log_time)
#ifndef SPDLOG_NO_THREAD_ID
, thread_id(os::thread_id())
,
thread_id(os::thread_id())
#endif
, source(loc)
, payload(msg) {
,
source(loc),
payload(msg) {
}
SPDLOG_INLINE log_msg::log_msg(spdlog::source_loc loc,

View File

@ -37,9 +37,9 @@ struct async_msg : log_msg_buffer {
// support for vs2013 move
#if defined(_MSC_VER) && _MSC_VER <= 1800
async_msg(async_msg &&other)
: log_msg_buffer(std::move(other))
, msg_type(other.msg_type)
, worker_ptr(std::move(other.worker_ptr)) {}
: log_msg_buffer(std::move(other)),
msg_type(other.msg_type),
worker_ptr(std::move(other.worker_ptr)) {}
async_msg &operator=(async_msg &&other) {
*static_cast<log_msg_buffer *>(this) = std::move(other);
@ -54,14 +54,14 @@ struct async_msg : log_msg_buffer {
// construct from log_msg with given type
async_msg(async_logger_ptr &&worker, async_msg_type the_type, const details::log_msg &m)
: log_msg_buffer{m}
, msg_type{the_type}
, worker_ptr{std::move(worker)} {}
: 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{}
, msg_type{the_type}
, worker_ptr{std::move(worker)} {}
: log_msg_buffer{},
msg_type{the_type},
worker_ptr{std::move(worker)} {}
explicit async_msg(async_msg_type the_type)
: async_msg{nullptr, the_type} {}

View File

@ -43,9 +43,9 @@ template <typename It>
class dump_info {
public:
dump_info(It range_begin, It range_end, size_t size_per_line)
: begin_(range_begin)
, end_(range_end)
, size_per_line_(size_per_line) {}
: begin_(range_begin),
end_(range_end),
size_per_line_(size_per_line) {}
// do not use begin() and end() to avoid collision with fmt/ranges
It get_begin() const { return begin_; }

View File

@ -17,12 +17,12 @@ namespace spdlog {
// public methods
SPDLOG_INLINE logger::logger(const logger &other)
: name_(other.name_)
, sinks_(other.sinks_)
, level_(other.level_.load(std::memory_order_relaxed))
, flush_level_(other.flush_level_.load(std::memory_order_relaxed))
, custom_err_handler_(other.custom_err_handler_)
, tracer_(other.tracer_) {}
: name_(other.name_),
sinks_(other.sinks_),
level_(other.level_.load(std::memory_order_relaxed)),
flush_level_(other.flush_level_.load(std::memory_order_relaxed)),
custom_err_handler_(other.custom_err_handler_),
tracer_(other.tracer_) {}
SPDLOG_INLINE logger::logger(logger &&other) SPDLOG_NOEXCEPT
: name_(std::move(other.name_)),

View File

@ -51,14 +51,14 @@ class SPDLOG_API logger {
public:
// Empty logger
explicit logger(std::string name)
: name_(std::move(name))
, sinks_() {}
: name_(std::move(name)),
sinks_() {}
// Logger with range on sinks
template <typename It>
logger(std::string name, It begin, It end)
: name_(std::move(name))
, sinks_(begin, end) {}
: name_(std::move(name)),
sinks_(begin, end) {}
// Logger with single sink
logger(std::string name, sink_ptr single_sink)

View File

@ -37,8 +37,8 @@ namespace details {
class scoped_padder {
public:
scoped_padder(size_t wrapped_size, const padding_info &padinfo, memory_buf_t &dest)
: padinfo_(padinfo)
, dest_(dest) {
: padinfo_(padinfo),
dest_(dest) {
remaining_pad_ = static_cast<long>(padinfo.width_) - static_cast<long>(wrapped_size);
if (remaining_pad_ <= 0) {
return;
@ -766,8 +766,8 @@ public:
using DurationUnits = Units;
explicit elapsed_formatter(padding_info padinfo)
: flag_formatter(padinfo)
, last_message_time_(log_clock::now()) {}
: flag_formatter(padinfo),
last_message_time_(log_clock::now()) {}
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
auto delta = (std::max)(msg.time - last_message_time_, log_clock::duration::zero());
@ -873,23 +873,23 @@ SPDLOG_INLINE pattern_formatter::pattern_formatter(std::string pattern,
pattern_time_type time_type,
std::string eol,
custom_flags custom_user_flags)
: pattern_(std::move(pattern))
, eol_(std::move(eol))
, pattern_time_type_(time_type)
, need_localtime_(false)
, last_log_secs_(0)
, custom_handlers_(std::move(custom_user_flags)) {
: pattern_(std::move(pattern)),
eol_(std::move(eol)),
pattern_time_type_(time_type),
need_localtime_(false),
last_log_secs_(0),
custom_handlers_(std::move(custom_user_flags)) {
std::memset(&cached_tm_, 0, sizeof(cached_tm_));
compile_pattern_(pattern_);
}
// use by default full formatter for if pattern is not given
SPDLOG_INLINE pattern_formatter::pattern_formatter(pattern_time_type time_type, std::string eol)
: pattern_("%+")
, eol_(std::move(eol))
, pattern_time_type_(time_type)
, need_localtime_(true)
, last_log_secs_(0) {
: pattern_("%+"),
eol_(std::move(eol)),
pattern_time_type_(time_type),
need_localtime_(true),
last_log_secs_(0) {
std::memset(&cached_tm_, 0, sizeof(cached_tm_));
formatters_.push_back(details::make_unique<details::full_formatter>(details::padding_info{}));
}

View File

@ -25,10 +25,10 @@ struct padding_info {
padding_info() = default;
padding_info(size_t width, padding_info::pad_side side, bool truncate)
: width_(width)
, side_(side)
, truncate_(truncate)
, enabled_(true) {}
: width_(width),
side_(side),
truncate_(truncate),
enabled_(true) {}
bool enabled() const { return enabled_; }
size_t width_ = 0;

View File

@ -34,8 +34,8 @@ template <typename Mutex, int BufferID = log_id::LOG_ID_MAIN>
class android_sink final : public base_sink<Mutex> {
public:
explicit android_sink(std::string tag = "spdlog", bool use_raw_msg = false)
: tag_(std::move(tag))
, use_raw_msg_(use_raw_msg) {}
: tag_(std::move(tag)),
use_raw_msg_(use_raw_msg) {}
protected:
void sink_it_(const details::log_msg &msg) override {

View File

@ -15,9 +15,9 @@ namespace sinks {
template <typename ConsoleMutex>
SPDLOG_INLINE ansicolor_sink<ConsoleMutex>::ansicolor_sink(FILE *target_file, color_mode mode)
: target_file_(target_file)
, mutex_(ConsoleMutex::mutex())
, formatter_(details::make_unique<spdlog::pattern_formatter>())
: target_file_(target_file),
mutex_(ConsoleMutex::mutex()),
formatter_(details::make_unique<spdlog::pattern_formatter>())
{
set_color_mode(mode);

View File

@ -73,13 +73,13 @@ public:
bool truncate = false,
uint16_t max_files = 0,
const file_event_handlers &event_handlers = {})
: base_filename_(std::move(base_filename))
, rotation_h_(rotation_hour)
, rotation_m_(rotation_minute)
, file_helper_{event_handlers}
, truncate_(truncate)
, max_files_(max_files)
, filenames_q_() {
: base_filename_(std::move(base_filename)),
rotation_h_(rotation_hour),
rotation_m_(rotation_minute),
file_helper_{event_handlers},
truncate_(truncate),
max_files_(max_files),
filenames_q_() {
if (rotation_hour < 0 || rotation_hour > 23 || rotation_minute < 0 ||
rotation_minute > 59) {
throw_spdlog_ex("daily_file_sink: Invalid rotation time in ctor");

View File

@ -42,8 +42,8 @@ public:
template <class Rep, class Period>
explicit dup_filter_sink(std::chrono::duration<Rep, Period> max_skip_duration,
level::level_enum notification_level = level::info)
: max_skip_duration_{max_skip_duration}
, log_level_{notification_level} {}
: max_skip_duration_{max_skip_duration},
log_level_{notification_level} {}
protected:
std::chrono::microseconds max_skip_duration_;

View File

@ -48,11 +48,11 @@ public:
bool truncate = false,
uint16_t max_files = 0,
const file_event_handlers &event_handlers = {})
: base_filename_(std::move(base_filename))
, file_helper_{event_handlers}
, truncate_(truncate)
, max_files_(max_files)
, filenames_q_() {
: base_filename_(std::move(base_filename)),
file_helper_{event_handlers},
truncate_(truncate),
max_files_(max_files),
filenames_q_() {
auto now = log_clock::now();
auto filename = FileNameCalc::calc_filename(base_filename_, now_tm(now));
file_helper_.open(filename, truncate_);

View File

@ -30,9 +30,9 @@ struct kafka_sink_config {
int32_t flush_timeout_ms = 1000;
kafka_sink_config(std::string addr, std::string topic, int flush_timeout_ms = 1000)
: server_addr{std::move(addr)}
, produce_topic{std::move(topic)}
, flush_timeout_ms(flush_timeout_ms) {}
: server_addr{std::move(addr)},
produce_topic{std::move(topic)},
flush_timeout_ms(flush_timeout_ms) {}
};
template <typename Mutex>

View File

@ -40,9 +40,9 @@ public:
const std::string &db_name,
const std::string &collection_name,
const std::string &uri = "mongodb://localhost:27017")
: instance_(std::move(instance))
, db_name_(db_name)
, coll_name_(collection_name) {
: instance_(std::move(instance)),
db_name_(db_name),
coll_name_(collection_name) {
try {
client_ = spdlog::details::make_unique<mongocxx::client>(mongocxx::uri{uri});
} catch (const std::exception &e) {

View File

@ -15,8 +15,8 @@ template <typename Mutex>
class ostream_sink final : public base_sink<Mutex> {
public:
explicit ostream_sink(std::ostream &os, bool force_flush = false)
: ostream_(os)
, force_flush_(force_flush) {}
: ostream_(os),
force_flush_(force_flush) {}
ostream_sink(const ostream_sink &) = delete;
ostream_sink &operator=(const ostream_sink &) = delete;

View File

@ -30,8 +30,8 @@ template <typename Mutex>
class qt_sink : public base_sink<Mutex> {
public:
qt_sink(QObject *qt_object, std::string meta_method)
: qt_object_(qt_object)
, meta_method_(std::move(meta_method)) {
: qt_object_(qt_object),
meta_method_(std::move(meta_method)) {
if (!qt_object_) {
throw_spdlog_ex("qt_sink: qt_object is null");
}
@ -69,9 +69,9 @@ public:
int max_lines,
bool dark_colors = false,
bool is_utf8 = false)
: qt_text_edit_(qt_text_edit)
, max_lines_(max_lines)
, is_utf8_(is_utf8) {
: qt_text_edit_(qt_text_edit),
max_lines_(max_lines),
is_utf8_(is_utf8) {
if (!qt_text_edit_) {
throw_spdlog_ex("qt_color_text_sink: text_edit is null");
}
@ -131,13 +131,13 @@ protected:
QTextCharFormat level_color,
int color_range_start,
int color_range_end)
: max_lines(max_lines)
, q_text_edit(q_text_edit)
, payload(std::move(payload))
, default_color(default_color)
, level_color(level_color)
, color_range_start(color_range_start)
, color_range_end(color_range_end) {}
: max_lines(max_lines),
q_text_edit(q_text_edit),
payload(std::move(payload)),
default_color(default_color),
level_color(level_color),
color_range_start(color_range_start),
color_range_end(color_range_end) {}
int max_lines;
QTextEdit *q_text_edit;
QString payload;

View File

@ -30,10 +30,10 @@ rotating_file_sink<Mutex>::rotating_file_sink(filename_t base_filename,
std::size_t max_files,
bool rotate_on_open,
const file_event_handlers &event_handlers)
: base_filename_(std::move(base_filename))
, max_size_(max_size)
, max_files_(max_files)
, file_helper_{event_handlers} {
: base_filename_(std::move(base_filename)),
max_size_(max_size),
max_files_(max_files),
file_helper_{event_handlers} {
if (max_size == 0) {
throw_spdlog_ex("rotating sink constructor: max_size arg cannot be zero");
}

View File

@ -30,9 +30,9 @@ namespace sinks {
template <typename ConsoleMutex>
SPDLOG_INLINE stdout_sink_base<ConsoleMutex>::stdout_sink_base(FILE *file)
: mutex_(ConsoleMutex::mutex())
, file_(file)
, formatter_(details::make_unique<spdlog::pattern_formatter>()) {
: mutex_(ConsoleMutex::mutex()),
file_(file),
formatter_(details::make_unique<spdlog::pattern_formatter>()) {
#ifdef _WIN32
// get windows handle from the FILE* object

View File

@ -21,15 +21,15 @@ class syslog_sink : public base_sink<Mutex> {
public:
syslog_sink(std::string ident, int syslog_option, int syslog_facility, bool enable_formatting)
: enable_formatting_{enable_formatting}
, syslog_levels_{{/* spdlog::level::trace */ LOG_DEBUG,
: enable_formatting_{enable_formatting},
syslog_levels_{{/* spdlog::level::trace */ LOG_DEBUG,
/* spdlog::level::debug */ LOG_DEBUG,
/* spdlog::level::info */ LOG_INFO,
/* spdlog::level::warn */ LOG_WARNING,
/* spdlog::level::err */ LOG_ERR,
/* spdlog::level::critical */ LOG_CRIT,
/* spdlog::level::off */ LOG_INFO}}
, ident_{std::move(ident)} {
/* spdlog::level::off */ LOG_INFO}},
ident_{std::move(ident)} {
// set ident to be program name if empty
::openlog(ident_.empty() ? nullptr : ident_.c_str(), syslog_option, syslog_facility);
}

View File

@ -24,9 +24,9 @@ template <typename Mutex>
class systemd_sink : public base_sink<Mutex> {
public:
systemd_sink(std::string ident = "", bool enable_formatting = false)
: ident_{std::move(ident)}
, enable_formatting_{enable_formatting}
, syslog_levels_{{/* spdlog::level::trace */ LOG_DEBUG,
: ident_{std::move(ident)},
enable_formatting_{enable_formatting},
syslog_levels_{{/* spdlog::level::trace */ LOG_DEBUG,
/* spdlog::level::debug */ LOG_DEBUG,
/* spdlog::level::info */ LOG_INFO,
/* spdlog::level::warn */ LOG_WARNING,

View File

@ -34,8 +34,8 @@ struct tcp_sink_config {
bool lazy_connect = false; // if true connect on first log call instead of on construction
tcp_sink_config(std::string host, int port)
: server_host{std::move(host)}
, server_port{port} {}
: server_host{std::move(host)},
server_port{port} {}
};
template <typename Mutex>

View File

@ -28,8 +28,8 @@ struct udp_sink_config {
uint16_t server_port;
udp_sink_config(std::string host, uint16_t port)
: server_host{std::move(host)}
, server_port{port} {}
: server_host{std::move(host)},
server_port{port} {}
};
template <typename Mutex>

View File

@ -236,8 +236,8 @@ protected:
public:
win_eventlog_sink(std::string const &source,
DWORD event_id = 1000 /* according to mscoree.dll */)
: source_(source)
, event_id_(event_id) {
: source_(source),
event_id_(event_id) {
try {
current_user_sid_ = internal::sid_t::get_current_user_sid();
} catch (...) {

View File

@ -17,9 +17,9 @@ namespace spdlog {
namespace sinks {
template <typename ConsoleMutex>
SPDLOG_INLINE wincolor_sink<ConsoleMutex>::wincolor_sink(void *out_handle, color_mode mode)
: out_handle_(out_handle)
, mutex_(ConsoleMutex::mutex())
, formatter_(details::make_unique<spdlog::pattern_formatter>()) {
: out_handle_(out_handle),
mutex_(ConsoleMutex::mutex()),
formatter_(details::make_unique<spdlog::pattern_formatter>()) {
set_color_mode_impl(mode);
// set level colors