|
|
@ -27,8 +27,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;
|
|
|
@ -756,8 +756,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());
|
|
|
@ -863,23 +863,23 @@ 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
|
|
|
|
pattern_formatter::pattern_formatter(pattern_time_type time_type, std::string eol)
|
|
|
|
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(std::make_unique<details::full_formatter>(details::padding_info{}));
|
|
|
|
formatters_.push_back(std::make_unique<details::full_formatter>(details::padding_info{}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|