#include <common/macros.hpp>
-#include <string>
#include <cxxabi.h>
+#include <string>
+#include <utility>
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT
namespace fmt {
template <>
struct formatter<std::type_info> : formatter<std::string> {
- template <typename FormatCtx>
- typename FormatCtx::iterator format(const std::type_info& type_info, FormatCtx& ctx)
+ template <typename FormatContextType>
+ typename FormatContextType::iterator format(const std::type_info& type_info,
+ FormatContextType& ctx)
{
int status;
auto demangled_name =
};
} /* namespace fmt */
+namespace lttng {
+template <typename... FormattingArguments>
+std::string format(FormattingArguments&&...args)
+{
+ try {
+ return fmt::format(std::forward<FormattingArguments>(args)...);
+ } catch (const fmt::format_error& ex) {
+ return std::string("Failed to format string: ") += ex.what();
+ }
+}
+} /* namespace lttng */
+
#endif /* LTTNG_FORMAT_H */