Show source location if present in default formatter
This commit is contained in:
parent
3218caf34a
commit
a16ff07a06
@ -198,7 +198,7 @@ struct source_loc
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_CONSTEXPR bool empty() const
|
SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT
|
||||||
{
|
{
|
||||||
return line == 0;
|
return line == 0;
|
||||||
}
|
}
|
||||||
|
@ -896,6 +896,7 @@ public:
|
|||||||
using std::chrono::milliseconds;
|
using std::chrono::milliseconds;
|
||||||
using std::chrono::seconds;
|
using std::chrono::seconds;
|
||||||
|
|
||||||
|
|
||||||
#ifndef SPDLOG_NO_DATETIME
|
#ifndef SPDLOG_NO_DATETIME
|
||||||
|
|
||||||
// cache the date/time part for the next second.
|
// cache the date/time part for the next second.
|
||||||
@ -930,8 +931,9 @@ public:
|
|||||||
|
|
||||||
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(' ');
|
SPDLOG_CONSTEXPR string_view_t closing_bracket{"] "};
|
||||||
|
fmt_helper::append_string_view(closing_bracket, dest);
|
||||||
|
|
||||||
#else // no datetime needed
|
#else // no datetime needed
|
||||||
(void)tm_time;
|
(void)tm_time;
|
||||||
@ -943,8 +945,7 @@ public:
|
|||||||
dest.push_back('[');
|
dest.push_back('[');
|
||||||
// fmt_helper::append_str(*msg.logger_name, dest);
|
// fmt_helper::append_str(*msg.logger_name, dest);
|
||||||
fmt_helper::append_string_view(*msg.logger_name, dest);
|
fmt_helper::append_string_view(*msg.logger_name, dest);
|
||||||
dest.push_back(']');
|
fmt_helper::append_string_view(closing_bracket, dest);
|
||||||
dest.push_back(' ');
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -954,8 +955,17 @@ public:
|
|||||||
// fmt_helper::append_string_view(level::to_c_str(msg.level), dest);
|
// fmt_helper::append_string_view(level::to_c_str(msg.level), dest);
|
||||||
fmt_helper::append_string_view(level::to_c_str(msg.level), dest);
|
fmt_helper::append_string_view(level::to_c_str(msg.level), dest);
|
||||||
msg.color_range_end = dest.size();
|
msg.color_range_end = dest.size();
|
||||||
dest.push_back(']');
|
fmt_helper::append_string_view(closing_bracket, dest);
|
||||||
dest.push_back(' ');
|
|
||||||
|
// add soruce location if present
|
||||||
|
if (!msg.source.empty())
|
||||||
|
{
|
||||||
|
dest.push_back('[');
|
||||||
|
fmt_helper::append_string_view(msg.source.filename, dest);
|
||||||
|
dest.push_back(':');
|
||||||
|
fmt_helper::append_int(msg.source.line, dest);
|
||||||
|
fmt_helper::append_string_view(closing_bracket, dest);
|
||||||
|
}
|
||||||
// fmt_helper::append_string_view(msg.msg(), dest);
|
// fmt_helper::append_string_view(msg.msg(), dest);
|
||||||
fmt_helper::append_string_view(msg.payload, dest);
|
fmt_helper::append_string_view(msg.payload, dest);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user