mirror of
https://github.com/gabime/spdlog.git
synced 2025-02-28 11:15:50 +08:00
code format
This commit is contained in:
parent
873026a254
commit
b9f0243405
@ -744,7 +744,8 @@ private:
|
|||||||
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] [%s:%#] %v
|
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] [%s:%#] %v
|
||||||
class default_format_formatter final : public flag_formatter {
|
class default_format_formatter final : public flag_formatter {
|
||||||
public:
|
public:
|
||||||
// log level names all with same width.
|
// clang-format off
|
||||||
|
// aligned level names
|
||||||
static constexpr std::string_view trace_str = "[trace] ";
|
static constexpr std::string_view trace_str = "[trace] ";
|
||||||
static constexpr std::string_view debug_str = "[debug] ";
|
static constexpr std::string_view debug_str = "[debug] ";
|
||||||
static constexpr std::string_view info_str = "[info ] ";
|
static constexpr std::string_view info_str = "[info ] ";
|
||||||
@ -752,7 +753,9 @@ public:
|
|||||||
static constexpr std::string_view error_str = "[error] ";
|
static constexpr std::string_view error_str = "[error] ";
|
||||||
static constexpr std::string_view critical_str = "[crit ] ";
|
static constexpr std::string_view critical_str = "[crit ] ";
|
||||||
static constexpr std::string_view off_str = "[off ] ";
|
static constexpr std::string_view off_str = "[off ] ";
|
||||||
static constexpr std::array<std::string_view, levels_count> padded_levels{{trace_str, debug_str, info_str, warn_str, error_str, critical_str, off_str}};
|
// clang-format on
|
||||||
|
static constexpr std::array<std::string_view, levels_count> padded_levels{
|
||||||
|
{trace_str, debug_str, info_str, warn_str, error_str, critical_str, off_str}};
|
||||||
|
|
||||||
explicit default_format_formatter(padding_info padinfo)
|
explicit default_format_formatter(padding_info padinfo)
|
||||||
: flag_formatter(padinfo) {}
|
: flag_formatter(padinfo) {}
|
||||||
@ -790,13 +793,13 @@ public:
|
|||||||
cache_timestamp_ = secs;
|
cache_timestamp_ = secs;
|
||||||
}
|
}
|
||||||
dest.append(cached_datetime_.begin(), cached_datetime_.end());
|
dest.append(cached_datetime_.begin(), cached_datetime_.end());
|
||||||
|
// append milliseconds
|
||||||
auto millis = fmt_helper::time_fraction<milliseconds>(msg.time);
|
auto millis = fmt_helper::time_fraction<milliseconds>(msg.time);
|
||||||
fmt_helper::pad3(static_cast<uint32_t>(millis.count()), dest);
|
fmt_helper::pad3(static_cast<uint32_t>(millis.count()), dest);
|
||||||
dest.push_back(']');
|
dest.push_back(']');
|
||||||
dest.push_back(' ');
|
dest.push_back(' ');
|
||||||
|
|
||||||
// append logger name if exists
|
// append aligned logger name if exists
|
||||||
if (!msg.logger_name.empty()) {
|
if (!msg.logger_name.empty()) {
|
||||||
dest.push_back('[');
|
dest.push_back('[');
|
||||||
fmt_helper::append_string_view(msg.logger_name, dest);
|
fmt_helper::append_string_view(msg.logger_name, dest);
|
||||||
|
Loading…
Reference in New Issue
Block a user