X-Git-Url: https://git.liburcu.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fformat.hpp;h=c1ab3d54ddc33cad2fb4a2b1c91aeab7ae2338dc;hp=389bc596ad85787c7f00aa7506532f56898551cf;hb=f9a4135756da1947c2aa00e5b1e3c8e572d02107;hpb=d5ed3e6f3a8b52d7f2a3e2277873e0f1914ba515 diff --git a/src/common/format.hpp b/src/common/format.hpp index 389bc596a..c1ab3d54d 100644 --- a/src/common/format.hpp +++ b/src/common/format.hpp @@ -11,6 +11,7 @@ #include #include +#include DIAGNOSTIC_PUSH DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT @@ -42,4 +43,16 @@ struct formatter : formatter { }; } /* namespace fmt */ +namespace lttng { +template +std::string format(FormattingArguments&&...args) +{ + try { + return fmt::format(std::forward(args)...); + } catch (const fmt::format_error& ex) { + return std::string("Failed to format string: ") += ex.what(); + } +} +} /* namespace lttng */ + #endif /* LTTNG_FORMAT_H */