Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ enum class Level : uint8_t {
Trace = 5, // -vv
};

// FIXME: duplicate code in Rustify/Tests.hpp but don't want to include it here.
// Maybe wait for modules to be stable?
constexpr std::string_view
prettifyFuncName(std::string_view func) noexcept {
if (func.empty()) {
return func;
}

const size_t end = func.find_last_of('(');
if (end == std::string_view::npos) {
return func;
}
func = func.substr(0, end);

const size_t start = func.find_last_of(' ');
if (start == std::string_view::npos) {
return func;
}
return func.substr(start + 1);
}

template <typename Fn>
concept HeadProcessor = std::is_nothrow_invocable_v<Fn, std::string_view>
&& Display<std::invoke_result_t<Fn, std::string_view>>;
Expand Down Expand Up @@ -118,7 +139,8 @@ class Logger {
level,
[lvlStr](const std::string_view func) noexcept {
return fmt::format(
"{}Poac {} {}{} ", gray("["), lvlStr, func, gray("]")
"{}Poac {} {}{} ", gray("["), lvlStr, prettifyFuncName(func),
gray("]")
);
},
func, fmt, std::forward<Args>(args)...
Expand Down
Loading