mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 08:25:43 +08:00
reformat code
This commit is contained in:
parent
cafde8ccc1
commit
4b2a8219d5
@ -41,9 +41,9 @@ public:
|
|||||||
It end,
|
It end,
|
||||||
std::weak_ptr<details::thread_pool> tp,
|
std::weak_ptr<details::thread_pool> tp,
|
||||||
async_overflow_policy overflow_policy = async_overflow_policy::block)
|
async_overflow_policy overflow_policy = async_overflow_policy::block)
|
||||||
: logger(std::move(logger_name), begin, end)
|
: logger(std::move(logger_name), begin, end),
|
||||||
, thread_pool_(std::move(tp))
|
thread_pool_(std::move(tp)),
|
||||||
, overflow_policy_(overflow_policy) {}
|
overflow_policy_(overflow_policy) {}
|
||||||
|
|
||||||
async_logger(std::string logger_name,
|
async_logger(std::string logger_name,
|
||||||
sinks_init_list sinks_list,
|
sinks_init_list sinks_list,
|
||||||
|
@ -306,9 +306,9 @@ private:
|
|||||||
struct source_loc {
|
struct source_loc {
|
||||||
SPDLOG_CONSTEXPR source_loc() = default;
|
SPDLOG_CONSTEXPR source_loc() = default;
|
||||||
SPDLOG_CONSTEXPR source_loc(const char *filename_in, int line_in, const char *funcname_in)
|
SPDLOG_CONSTEXPR source_loc(const char *filename_in, int line_in, const char *funcname_in)
|
||||||
: filename{filename_in}
|
: filename{filename_in},
|
||||||
, line{line_in}
|
line{line_in},
|
||||||
, funcname{funcname_in} {}
|
funcname{funcname_in} {}
|
||||||
|
|
||||||
SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT { return line == 0; }
|
SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT { return line == 0; }
|
||||||
const char *filename{nullptr};
|
const char *filename{nullptr};
|
||||||
@ -318,10 +318,10 @@ struct source_loc {
|
|||||||
|
|
||||||
struct file_event_handlers {
|
struct file_event_handlers {
|
||||||
file_event_handlers()
|
file_event_handlers()
|
||||||
: before_open(nullptr)
|
: before_open(nullptr),
|
||||||
, after_open(nullptr)
|
after_open(nullptr),
|
||||||
, before_close(nullptr)
|
before_close(nullptr),
|
||||||
, after_close(nullptr) {}
|
after_close(nullptr) {}
|
||||||
|
|
||||||
std::function<void(const filename_t &filename)> before_open;
|
std::function<void(const filename_t &filename)> before_open;
|
||||||
std::function<void(const filename_t &filename, std::FILE *file_stream)> after_open;
|
std::function<void(const filename_t &filename, std::FILE *file_stream)> after_open;
|
||||||
|
@ -25,7 +25,8 @@ public:
|
|||||||
|
|
||||||
explicit circular_q(size_t max_items)
|
explicit circular_q(size_t max_items)
|
||||||
: max_items_(max_items + 1) // one item is reserved as marker for full q
|
: 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(const circular_q &) = default;
|
||||||
circular_q &operator=(const circular_q &) = default;
|
circular_q &operator=(const circular_q &) = default;
|
||||||
|
@ -17,14 +17,16 @@ SPDLOG_INLINE log_msg::log_msg(spdlog::log_clock::time_point log_time,
|
|||||||
string_view_t a_logger_name,
|
string_view_t a_logger_name,
|
||||||
spdlog::level::level_enum lvl,
|
spdlog::level::level_enum lvl,
|
||||||
spdlog::string_view_t msg)
|
spdlog::string_view_t msg)
|
||||||
: logger_name(a_logger_name)
|
: logger_name(a_logger_name),
|
||||||
, level(lvl)
|
level(lvl),
|
||||||
, time(log_time)
|
time(log_time)
|
||||||
#ifndef SPDLOG_NO_THREAD_ID
|
#ifndef SPDLOG_NO_THREAD_ID
|
||||||
, thread_id(os::thread_id())
|
,
|
||||||
|
thread_id(os::thread_id())
|
||||||
#endif
|
#endif
|
||||||
, source(loc)
|
,
|
||||||
, payload(msg) {
|
source(loc),
|
||||||
|
payload(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_INLINE log_msg::log_msg(spdlog::source_loc loc,
|
SPDLOG_INLINE log_msg::log_msg(spdlog::source_loc loc,
|
||||||
|
@ -37,9 +37,9 @@ struct async_msg : log_msg_buffer {
|
|||||||
// support for vs2013 move
|
// support for vs2013 move
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1800
|
#if defined(_MSC_VER) && _MSC_VER <= 1800
|
||||||
async_msg(async_msg &&other)
|
async_msg(async_msg &&other)
|
||||||
: log_msg_buffer(std::move(other))
|
: log_msg_buffer(std::move(other)),
|
||||||
, msg_type(other.msg_type)
|
msg_type(other.msg_type),
|
||||||
, worker_ptr(std::move(other.worker_ptr)) {}
|
worker_ptr(std::move(other.worker_ptr)) {}
|
||||||
|
|
||||||
async_msg &operator=(async_msg &&other) {
|
async_msg &operator=(async_msg &&other) {
|
||||||
*static_cast<log_msg_buffer *>(this) = std::move(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
|
// construct from log_msg with given type
|
||||||
async_msg(async_logger_ptr &&worker, async_msg_type the_type, const details::log_msg &m)
|
async_msg(async_logger_ptr &&worker, async_msg_type the_type, const details::log_msg &m)
|
||||||
: log_msg_buffer{m}
|
: log_msg_buffer{m},
|
||||||
, msg_type{the_type}
|
msg_type{the_type},
|
||||||
, worker_ptr{std::move(worker)} {}
|
worker_ptr{std::move(worker)} {}
|
||||||
|
|
||||||
async_msg(async_logger_ptr &&worker, async_msg_type the_type)
|
async_msg(async_logger_ptr &&worker, async_msg_type the_type)
|
||||||
: log_msg_buffer{}
|
: log_msg_buffer{},
|
||||||
, msg_type{the_type}
|
msg_type{the_type},
|
||||||
, worker_ptr{std::move(worker)} {}
|
worker_ptr{std::move(worker)} {}
|
||||||
|
|
||||||
explicit async_msg(async_msg_type the_type)
|
explicit async_msg(async_msg_type the_type)
|
||||||
: async_msg{nullptr, the_type} {}
|
: async_msg{nullptr, the_type} {}
|
||||||
|
@ -43,9 +43,9 @@ template <typename It>
|
|||||||
class dump_info {
|
class dump_info {
|
||||||
public:
|
public:
|
||||||
dump_info(It range_begin, It range_end, size_t size_per_line)
|
dump_info(It range_begin, It range_end, size_t size_per_line)
|
||||||
: begin_(range_begin)
|
: begin_(range_begin),
|
||||||
, end_(range_end)
|
end_(range_end),
|
||||||
, size_per_line_(size_per_line) {}
|
size_per_line_(size_per_line) {}
|
||||||
|
|
||||||
// do not use begin() and end() to avoid collision with fmt/ranges
|
// do not use begin() and end() to avoid collision with fmt/ranges
|
||||||
It get_begin() const { return begin_; }
|
It get_begin() const { return begin_; }
|
||||||
|
@ -17,12 +17,12 @@ namespace spdlog {
|
|||||||
|
|
||||||
// public methods
|
// public methods
|
||||||
SPDLOG_INLINE logger::logger(const logger &other)
|
SPDLOG_INLINE logger::logger(const logger &other)
|
||||||
: name_(other.name_)
|
: name_(other.name_),
|
||||||
, sinks_(other.sinks_)
|
sinks_(other.sinks_),
|
||||||
, level_(other.level_.load(std::memory_order_relaxed))
|
level_(other.level_.load(std::memory_order_relaxed)),
|
||||||
, flush_level_(other.flush_level_.load(std::memory_order_relaxed))
|
flush_level_(other.flush_level_.load(std::memory_order_relaxed)),
|
||||||
, custom_err_handler_(other.custom_err_handler_)
|
custom_err_handler_(other.custom_err_handler_),
|
||||||
, tracer_(other.tracer_) {}
|
tracer_(other.tracer_) {}
|
||||||
|
|
||||||
SPDLOG_INLINE logger::logger(logger &&other) SPDLOG_NOEXCEPT
|
SPDLOG_INLINE logger::logger(logger &&other) SPDLOG_NOEXCEPT
|
||||||
: name_(std::move(other.name_)),
|
: name_(std::move(other.name_)),
|
||||||
|
@ -51,14 +51,14 @@ class SPDLOG_API logger {
|
|||||||
public:
|
public:
|
||||||
// Empty logger
|
// Empty logger
|
||||||
explicit logger(std::string name)
|
explicit logger(std::string name)
|
||||||
: name_(std::move(name))
|
: name_(std::move(name)),
|
||||||
, sinks_() {}
|
sinks_() {}
|
||||||
|
|
||||||
// Logger with range on sinks
|
// Logger with range on sinks
|
||||||
template <typename It>
|
template <typename It>
|
||||||
logger(std::string name, It begin, It end)
|
logger(std::string name, It begin, It end)
|
||||||
: name_(std::move(name))
|
: name_(std::move(name)),
|
||||||
, sinks_(begin, end) {}
|
sinks_(begin, end) {}
|
||||||
|
|
||||||
// Logger with single sink
|
// Logger with single sink
|
||||||
logger(std::string name, sink_ptr single_sink)
|
logger(std::string name, sink_ptr single_sink)
|
||||||
|
@ -37,8 +37,8 @@ namespace details {
|
|||||||
class scoped_padder {
|
class scoped_padder {
|
||||||
public:
|
public:
|
||||||
scoped_padder(size_t wrapped_size, const padding_info &padinfo, memory_buf_t &dest)
|
scoped_padder(size_t wrapped_size, const padding_info &padinfo, memory_buf_t &dest)
|
||||||
: padinfo_(padinfo)
|
: padinfo_(padinfo),
|
||||||
, dest_(dest) {
|
dest_(dest) {
|
||||||
remaining_pad_ = static_cast<long>(padinfo.width_) - static_cast<long>(wrapped_size);
|
remaining_pad_ = static_cast<long>(padinfo.width_) - static_cast<long>(wrapped_size);
|
||||||
if (remaining_pad_ <= 0) {
|
if (remaining_pad_ <= 0) {
|
||||||
return;
|
return;
|
||||||
@ -766,8 +766,8 @@ public:
|
|||||||
using DurationUnits = Units;
|
using DurationUnits = Units;
|
||||||
|
|
||||||
explicit elapsed_formatter(padding_info padinfo)
|
explicit elapsed_formatter(padding_info padinfo)
|
||||||
: flag_formatter(padinfo)
|
: flag_formatter(padinfo),
|
||||||
, last_message_time_(log_clock::now()) {}
|
last_message_time_(log_clock::now()) {}
|
||||||
|
|
||||||
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
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());
|
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,
|
pattern_time_type time_type,
|
||||||
std::string eol,
|
std::string eol,
|
||||||
custom_flags custom_user_flags)
|
custom_flags custom_user_flags)
|
||||||
: pattern_(std::move(pattern))
|
: pattern_(std::move(pattern)),
|
||||||
, eol_(std::move(eol))
|
eol_(std::move(eol)),
|
||||||
, pattern_time_type_(time_type)
|
pattern_time_type_(time_type),
|
||||||
, need_localtime_(false)
|
need_localtime_(false),
|
||||||
, last_log_secs_(0)
|
last_log_secs_(0),
|
||||||
, custom_handlers_(std::move(custom_user_flags)) {
|
custom_handlers_(std::move(custom_user_flags)) {
|
||||||
std::memset(&cached_tm_, 0, sizeof(cached_tm_));
|
std::memset(&cached_tm_, 0, sizeof(cached_tm_));
|
||||||
compile_pattern_(pattern_);
|
compile_pattern_(pattern_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use by default full formatter for if pattern is not given
|
// 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)
|
SPDLOG_INLINE pattern_formatter::pattern_formatter(pattern_time_type time_type, std::string eol)
|
||||||
: pattern_("%+")
|
: pattern_("%+"),
|
||||||
, eol_(std::move(eol))
|
eol_(std::move(eol)),
|
||||||
, pattern_time_type_(time_type)
|
pattern_time_type_(time_type),
|
||||||
, need_localtime_(true)
|
need_localtime_(true),
|
||||||
, last_log_secs_(0) {
|
last_log_secs_(0) {
|
||||||
std::memset(&cached_tm_, 0, sizeof(cached_tm_));
|
std::memset(&cached_tm_, 0, sizeof(cached_tm_));
|
||||||
formatters_.push_back(details::make_unique<details::full_formatter>(details::padding_info{}));
|
formatters_.push_back(details::make_unique<details::full_formatter>(details::padding_info{}));
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,10 @@ struct padding_info {
|
|||||||
|
|
||||||
padding_info() = default;
|
padding_info() = default;
|
||||||
padding_info(size_t width, padding_info::pad_side side, bool truncate)
|
padding_info(size_t width, padding_info::pad_side side, bool truncate)
|
||||||
: width_(width)
|
: width_(width),
|
||||||
, side_(side)
|
side_(side),
|
||||||
, truncate_(truncate)
|
truncate_(truncate),
|
||||||
, enabled_(true) {}
|
enabled_(true) {}
|
||||||
|
|
||||||
bool enabled() const { return enabled_; }
|
bool enabled() const { return enabled_; }
|
||||||
size_t width_ = 0;
|
size_t width_ = 0;
|
||||||
|
@ -34,8 +34,8 @@ template <typename Mutex, int BufferID = log_id::LOG_ID_MAIN>
|
|||||||
class android_sink final : public base_sink<Mutex> {
|
class android_sink final : public base_sink<Mutex> {
|
||||||
public:
|
public:
|
||||||
explicit android_sink(std::string tag = "spdlog", bool use_raw_msg = false)
|
explicit android_sink(std::string tag = "spdlog", bool use_raw_msg = false)
|
||||||
: tag_(std::move(tag))
|
: tag_(std::move(tag)),
|
||||||
, use_raw_msg_(use_raw_msg) {}
|
use_raw_msg_(use_raw_msg) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void sink_it_(const details::log_msg &msg) override {
|
void sink_it_(const details::log_msg &msg) override {
|
||||||
|
@ -15,9 +15,9 @@ namespace sinks {
|
|||||||
|
|
||||||
template <typename ConsoleMutex>
|
template <typename ConsoleMutex>
|
||||||
SPDLOG_INLINE ansicolor_sink<ConsoleMutex>::ansicolor_sink(FILE *target_file, color_mode mode)
|
SPDLOG_INLINE ansicolor_sink<ConsoleMutex>::ansicolor_sink(FILE *target_file, color_mode mode)
|
||||||
: target_file_(target_file)
|
: target_file_(target_file),
|
||||||
, mutex_(ConsoleMutex::mutex())
|
mutex_(ConsoleMutex::mutex()),
|
||||||
, formatter_(details::make_unique<spdlog::pattern_formatter>())
|
formatter_(details::make_unique<spdlog::pattern_formatter>())
|
||||||
|
|
||||||
{
|
{
|
||||||
set_color_mode(mode);
|
set_color_mode(mode);
|
||||||
|
@ -73,13 +73,13 @@ public:
|
|||||||
bool truncate = false,
|
bool truncate = false,
|
||||||
uint16_t max_files = 0,
|
uint16_t max_files = 0,
|
||||||
const file_event_handlers &event_handlers = {})
|
const file_event_handlers &event_handlers = {})
|
||||||
: base_filename_(std::move(base_filename))
|
: base_filename_(std::move(base_filename)),
|
||||||
, rotation_h_(rotation_hour)
|
rotation_h_(rotation_hour),
|
||||||
, rotation_m_(rotation_minute)
|
rotation_m_(rotation_minute),
|
||||||
, file_helper_{event_handlers}
|
file_helper_{event_handlers},
|
||||||
, truncate_(truncate)
|
truncate_(truncate),
|
||||||
, max_files_(max_files)
|
max_files_(max_files),
|
||||||
, filenames_q_() {
|
filenames_q_() {
|
||||||
if (rotation_hour < 0 || rotation_hour > 23 || rotation_minute < 0 ||
|
if (rotation_hour < 0 || rotation_hour > 23 || rotation_minute < 0 ||
|
||||||
rotation_minute > 59) {
|
rotation_minute > 59) {
|
||||||
throw_spdlog_ex("daily_file_sink: Invalid rotation time in ctor");
|
throw_spdlog_ex("daily_file_sink: Invalid rotation time in ctor");
|
||||||
|
@ -42,8 +42,8 @@ public:
|
|||||||
template <class Rep, class Period>
|
template <class Rep, class Period>
|
||||||
explicit dup_filter_sink(std::chrono::duration<Rep, Period> max_skip_duration,
|
explicit dup_filter_sink(std::chrono::duration<Rep, Period> max_skip_duration,
|
||||||
level::level_enum notification_level = level::info)
|
level::level_enum notification_level = level::info)
|
||||||
: max_skip_duration_{max_skip_duration}
|
: max_skip_duration_{max_skip_duration},
|
||||||
, log_level_{notification_level} {}
|
log_level_{notification_level} {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::chrono::microseconds max_skip_duration_;
|
std::chrono::microseconds max_skip_duration_;
|
||||||
|
@ -48,11 +48,11 @@ public:
|
|||||||
bool truncate = false,
|
bool truncate = false,
|
||||||
uint16_t max_files = 0,
|
uint16_t max_files = 0,
|
||||||
const file_event_handlers &event_handlers = {})
|
const file_event_handlers &event_handlers = {})
|
||||||
: base_filename_(std::move(base_filename))
|
: base_filename_(std::move(base_filename)),
|
||||||
, file_helper_{event_handlers}
|
file_helper_{event_handlers},
|
||||||
, truncate_(truncate)
|
truncate_(truncate),
|
||||||
, max_files_(max_files)
|
max_files_(max_files),
|
||||||
, filenames_q_() {
|
filenames_q_() {
|
||||||
auto now = log_clock::now();
|
auto now = log_clock::now();
|
||||||
auto filename = FileNameCalc::calc_filename(base_filename_, now_tm(now));
|
auto filename = FileNameCalc::calc_filename(base_filename_, now_tm(now));
|
||||||
file_helper_.open(filename, truncate_);
|
file_helper_.open(filename, truncate_);
|
||||||
|
@ -30,9 +30,9 @@ struct kafka_sink_config {
|
|||||||
int32_t flush_timeout_ms = 1000;
|
int32_t flush_timeout_ms = 1000;
|
||||||
|
|
||||||
kafka_sink_config(std::string addr, std::string topic, int flush_timeout_ms = 1000)
|
kafka_sink_config(std::string addr, std::string topic, int flush_timeout_ms = 1000)
|
||||||
: server_addr{std::move(addr)}
|
: server_addr{std::move(addr)},
|
||||||
, produce_topic{std::move(topic)}
|
produce_topic{std::move(topic)},
|
||||||
, flush_timeout_ms(flush_timeout_ms) {}
|
flush_timeout_ms(flush_timeout_ms) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Mutex>
|
template <typename Mutex>
|
||||||
|
@ -40,9 +40,9 @@ public:
|
|||||||
const std::string &db_name,
|
const std::string &db_name,
|
||||||
const std::string &collection_name,
|
const std::string &collection_name,
|
||||||
const std::string &uri = "mongodb://localhost:27017")
|
const std::string &uri = "mongodb://localhost:27017")
|
||||||
: instance_(std::move(instance))
|
: instance_(std::move(instance)),
|
||||||
, db_name_(db_name)
|
db_name_(db_name),
|
||||||
, coll_name_(collection_name) {
|
coll_name_(collection_name) {
|
||||||
try {
|
try {
|
||||||
client_ = spdlog::details::make_unique<mongocxx::client>(mongocxx::uri{uri});
|
client_ = spdlog::details::make_unique<mongocxx::client>(mongocxx::uri{uri});
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
|
@ -15,8 +15,8 @@ template <typename Mutex>
|
|||||||
class ostream_sink final : public base_sink<Mutex> {
|
class ostream_sink final : public base_sink<Mutex> {
|
||||||
public:
|
public:
|
||||||
explicit ostream_sink(std::ostream &os, bool force_flush = false)
|
explicit ostream_sink(std::ostream &os, bool force_flush = false)
|
||||||
: ostream_(os)
|
: ostream_(os),
|
||||||
, force_flush_(force_flush) {}
|
force_flush_(force_flush) {}
|
||||||
ostream_sink(const ostream_sink &) = delete;
|
ostream_sink(const ostream_sink &) = delete;
|
||||||
ostream_sink &operator=(const ostream_sink &) = delete;
|
ostream_sink &operator=(const ostream_sink &) = delete;
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ template <typename Mutex>
|
|||||||
class qt_sink : public base_sink<Mutex> {
|
class qt_sink : public base_sink<Mutex> {
|
||||||
public:
|
public:
|
||||||
qt_sink(QObject *qt_object, std::string meta_method)
|
qt_sink(QObject *qt_object, std::string meta_method)
|
||||||
: qt_object_(qt_object)
|
: qt_object_(qt_object),
|
||||||
, meta_method_(std::move(meta_method)) {
|
meta_method_(std::move(meta_method)) {
|
||||||
if (!qt_object_) {
|
if (!qt_object_) {
|
||||||
throw_spdlog_ex("qt_sink: qt_object is null");
|
throw_spdlog_ex("qt_sink: qt_object is null");
|
||||||
}
|
}
|
||||||
@ -69,9 +69,9 @@ public:
|
|||||||
int max_lines,
|
int max_lines,
|
||||||
bool dark_colors = false,
|
bool dark_colors = false,
|
||||||
bool is_utf8 = false)
|
bool is_utf8 = false)
|
||||||
: qt_text_edit_(qt_text_edit)
|
: qt_text_edit_(qt_text_edit),
|
||||||
, max_lines_(max_lines)
|
max_lines_(max_lines),
|
||||||
, is_utf8_(is_utf8) {
|
is_utf8_(is_utf8) {
|
||||||
if (!qt_text_edit_) {
|
if (!qt_text_edit_) {
|
||||||
throw_spdlog_ex("qt_color_text_sink: text_edit is null");
|
throw_spdlog_ex("qt_color_text_sink: text_edit is null");
|
||||||
}
|
}
|
||||||
@ -131,13 +131,13 @@ protected:
|
|||||||
QTextCharFormat level_color,
|
QTextCharFormat level_color,
|
||||||
int color_range_start,
|
int color_range_start,
|
||||||
int color_range_end)
|
int color_range_end)
|
||||||
: max_lines(max_lines)
|
: max_lines(max_lines),
|
||||||
, q_text_edit(q_text_edit)
|
q_text_edit(q_text_edit),
|
||||||
, payload(std::move(payload))
|
payload(std::move(payload)),
|
||||||
, default_color(default_color)
|
default_color(default_color),
|
||||||
, level_color(level_color)
|
level_color(level_color),
|
||||||
, color_range_start(color_range_start)
|
color_range_start(color_range_start),
|
||||||
, color_range_end(color_range_end) {}
|
color_range_end(color_range_end) {}
|
||||||
int max_lines;
|
int max_lines;
|
||||||
QTextEdit *q_text_edit;
|
QTextEdit *q_text_edit;
|
||||||
QString payload;
|
QString payload;
|
||||||
|
@ -30,10 +30,10 @@ rotating_file_sink<Mutex>::rotating_file_sink(filename_t base_filename,
|
|||||||
std::size_t max_files,
|
std::size_t max_files,
|
||||||
bool rotate_on_open,
|
bool rotate_on_open,
|
||||||
const file_event_handlers &event_handlers)
|
const file_event_handlers &event_handlers)
|
||||||
: base_filename_(std::move(base_filename))
|
: base_filename_(std::move(base_filename)),
|
||||||
, max_size_(max_size)
|
max_size_(max_size),
|
||||||
, max_files_(max_files)
|
max_files_(max_files),
|
||||||
, file_helper_{event_handlers} {
|
file_helper_{event_handlers} {
|
||||||
if (max_size == 0) {
|
if (max_size == 0) {
|
||||||
throw_spdlog_ex("rotating sink constructor: max_size arg cannot be zero");
|
throw_spdlog_ex("rotating sink constructor: max_size arg cannot be zero");
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ namespace sinks {
|
|||||||
|
|
||||||
template <typename ConsoleMutex>
|
template <typename ConsoleMutex>
|
||||||
SPDLOG_INLINE stdout_sink_base<ConsoleMutex>::stdout_sink_base(FILE *file)
|
SPDLOG_INLINE stdout_sink_base<ConsoleMutex>::stdout_sink_base(FILE *file)
|
||||||
: mutex_(ConsoleMutex::mutex())
|
: mutex_(ConsoleMutex::mutex()),
|
||||||
, file_(file)
|
file_(file),
|
||||||
, formatter_(details::make_unique<spdlog::pattern_formatter>()) {
|
formatter_(details::make_unique<spdlog::pattern_formatter>()) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// get windows handle from the FILE* object
|
// get windows handle from the FILE* object
|
||||||
|
|
||||||
|
@ -21,15 +21,15 @@ class syslog_sink : public base_sink<Mutex> {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
syslog_sink(std::string ident, int syslog_option, int syslog_facility, bool enable_formatting)
|
syslog_sink(std::string ident, int syslog_option, int syslog_facility, bool enable_formatting)
|
||||||
: enable_formatting_{enable_formatting}
|
: enable_formatting_{enable_formatting},
|
||||||
, syslog_levels_{{/* spdlog::level::trace */ LOG_DEBUG,
|
syslog_levels_{{/* spdlog::level::trace */ LOG_DEBUG,
|
||||||
/* spdlog::level::debug */ LOG_DEBUG,
|
/* spdlog::level::debug */ LOG_DEBUG,
|
||||||
/* spdlog::level::info */ LOG_INFO,
|
/* spdlog::level::info */ LOG_INFO,
|
||||||
/* spdlog::level::warn */ LOG_WARNING,
|
/* spdlog::level::warn */ LOG_WARNING,
|
||||||
/* spdlog::level::err */ LOG_ERR,
|
/* spdlog::level::err */ LOG_ERR,
|
||||||
/* spdlog::level::critical */ LOG_CRIT,
|
/* spdlog::level::critical */ LOG_CRIT,
|
||||||
/* spdlog::level::off */ LOG_INFO}}
|
/* spdlog::level::off */ LOG_INFO}},
|
||||||
, ident_{std::move(ident)} {
|
ident_{std::move(ident)} {
|
||||||
// set ident to be program name if empty
|
// set ident to be program name if empty
|
||||||
::openlog(ident_.empty() ? nullptr : ident_.c_str(), syslog_option, syslog_facility);
|
::openlog(ident_.empty() ? nullptr : ident_.c_str(), syslog_option, syslog_facility);
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ template <typename Mutex>
|
|||||||
class systemd_sink : public base_sink<Mutex> {
|
class systemd_sink : public base_sink<Mutex> {
|
||||||
public:
|
public:
|
||||||
systemd_sink(std::string ident = "", bool enable_formatting = false)
|
systemd_sink(std::string ident = "", bool enable_formatting = false)
|
||||||
: ident_{std::move(ident)}
|
: ident_{std::move(ident)},
|
||||||
, enable_formatting_{enable_formatting}
|
enable_formatting_{enable_formatting},
|
||||||
, syslog_levels_{{/* spdlog::level::trace */ LOG_DEBUG,
|
syslog_levels_{{/* spdlog::level::trace */ LOG_DEBUG,
|
||||||
/* spdlog::level::debug */ LOG_DEBUG,
|
/* spdlog::level::debug */ LOG_DEBUG,
|
||||||
/* spdlog::level::info */ LOG_INFO,
|
/* spdlog::level::info */ LOG_INFO,
|
||||||
/* spdlog::level::warn */ LOG_WARNING,
|
/* spdlog::level::warn */ LOG_WARNING,
|
||||||
|
@ -34,8 +34,8 @@ struct tcp_sink_config {
|
|||||||
bool lazy_connect = false; // if true connect on first log call instead of on construction
|
bool lazy_connect = false; // if true connect on first log call instead of on construction
|
||||||
|
|
||||||
tcp_sink_config(std::string host, int port)
|
tcp_sink_config(std::string host, int port)
|
||||||
: server_host{std::move(host)}
|
: server_host{std::move(host)},
|
||||||
, server_port{port} {}
|
server_port{port} {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Mutex>
|
template <typename Mutex>
|
||||||
|
@ -28,8 +28,8 @@ struct udp_sink_config {
|
|||||||
uint16_t server_port;
|
uint16_t server_port;
|
||||||
|
|
||||||
udp_sink_config(std::string host, uint16_t port)
|
udp_sink_config(std::string host, uint16_t port)
|
||||||
: server_host{std::move(host)}
|
: server_host{std::move(host)},
|
||||||
, server_port{port} {}
|
server_port{port} {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Mutex>
|
template <typename Mutex>
|
||||||
|
@ -236,8 +236,8 @@ protected:
|
|||||||
public:
|
public:
|
||||||
win_eventlog_sink(std::string const &source,
|
win_eventlog_sink(std::string const &source,
|
||||||
DWORD event_id = 1000 /* according to mscoree.dll */)
|
DWORD event_id = 1000 /* according to mscoree.dll */)
|
||||||
: source_(source)
|
: source_(source),
|
||||||
, event_id_(event_id) {
|
event_id_(event_id) {
|
||||||
try {
|
try {
|
||||||
current_user_sid_ = internal::sid_t::get_current_user_sid();
|
current_user_sid_ = internal::sid_t::get_current_user_sid();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
@ -17,9 +17,9 @@ namespace spdlog {
|
|||||||
namespace sinks {
|
namespace sinks {
|
||||||
template <typename ConsoleMutex>
|
template <typename ConsoleMutex>
|
||||||
SPDLOG_INLINE wincolor_sink<ConsoleMutex>::wincolor_sink(void *out_handle, color_mode mode)
|
SPDLOG_INLINE wincolor_sink<ConsoleMutex>::wincolor_sink(void *out_handle, color_mode mode)
|
||||||
: out_handle_(out_handle)
|
: out_handle_(out_handle),
|
||||||
, mutex_(ConsoleMutex::mutex())
|
mutex_(ConsoleMutex::mutex()),
|
||||||
, formatter_(details::make_unique<spdlog::pattern_formatter>()) {
|
formatter_(details::make_unique<spdlog::pattern_formatter>()) {
|
||||||
|
|
||||||
set_color_mode_impl(mode);
|
set_color_mode_impl(mode);
|
||||||
// set level colors
|
// set level colors
|
||||||
|
Loading…
Reference in New Issue
Block a user