]> git.lttng.org Git - lttng-tools.git/commitdiff
error: Add `PWARN_FMT` and `PERROR_FMT` macros
authorKienan Stewart <kstewart@efficios.com>
Wed, 11 Dec 2024 15:53:59 +0000 (10:53 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 18 Dec 2024 15:55:14 +0000 (15:55 +0000)
Change-Id: Ib46fbed81c429f54793c9787a537950faa5552e0
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/error.hpp

index 66f38bf2eca36e7e9356d9eb3fb837e6db4873bb..c78c492b8113292ac7b8f6aea0a434383a3792cc 100644 (file)
@@ -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
This page took 0.029427 seconds and 4 git commands to generate.