mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-02 11:29:01 +08:00
Allow filename/line number at all levels. Add function name %! support.
This commit is contained in:
@@ -895,6 +895,26 @@ public:
|
||||
}
|
||||
}
|
||||
};
|
||||
// print source funcname
|
||||
class source_funcname_formatter final : public flag_formatter
|
||||
{
|
||||
public:
|
||||
explicit source_funcname_formatter(padding_info padinfo)
|
||||
: flag_formatter(padinfo){};
|
||||
|
||||
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
|
||||
{
|
||||
if (msg.source.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
scoped_pad p(msg.source.funcname, padinfo_, dest);
|
||||
fmt_helper::append_string_view(msg.source.funcname, dest);
|
||||
#ifdef SPDLOG_FUNCTION_SUFFIX
|
||||
fmt_helper::append_string_view(SPDLOG_FUNCTION_SUFFIX, dest);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
// Full info formatter
|
||||
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] %v
|
||||
@@ -1216,6 +1236,10 @@ private:
|
||||
formatters_.push_back(details::make_unique<details::source_linenum_formatter>(padding));
|
||||
break;
|
||||
|
||||
case ('!'): // source funcname
|
||||
formatters_.push_back(details::make_unique<details::source_funcname_formatter>(padding));
|
||||
break;
|
||||
|
||||
case ('%'): // % char
|
||||
formatters_.push_back(details::make_unique<details::ch_formatter>('%'));
|
||||
break;
|
||||
|
Reference in New Issue
Block a user