From: Kienan Stewart Date: Wed, 11 Dec 2024 15:53:59 +0000 (-0500) Subject: error: Add `PWARN_FMT` and `PERROR_FMT` macros X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b89fd4a2af6c94d27e652fd20310da0f8526abbf;p=lttng-tools.git error: Add `PWARN_FMT` and `PERROR_FMT` macros Change-Id: Ib46fbed81c429f54793c9787a537950faa5552e0 Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/error.hpp b/src/common/error.hpp index 66f38bf2e..c78c492b8 100644 --- a/src/common/error.hpp +++ b/src/common/error.hpp @@ -308,6 +308,26 @@ namespace details { } \ } while (0); +#define PERROR_FMT(format_str, args...) \ + do { \ + try { \ + PERROR("%s", lttng::format(format_str, ##args).c_str()); \ + } catch (const std::exception& _formatting_exception) { \ + lttng::logging::details::die_formatting_exception(format_str, \ + _formatting_exception); \ + } \ + } while (0); + +#define PWARN_FMT(format_str, args...) \ + do { \ + try { \ + PWARN("%s", lttng::format(format_str, ##args).c_str()); \ + } catch (const std::exception& _formatting_exception) { \ + lttng::logging::details::die_formatting_exception(format_str, \ + _formatting_exception); \ + } \ + } while (0); + /* * Function that format the time and return the reference of log_time.str to * the caller. On error, an empty string is returned thus no time will be