Fix: logging: unhandled error in *_FMT macros
[lttng-tools.git] / src / common / error.cpp
index ab09053ccfb1465179139187069e73954a0b6f97..cafb15f92948b8ee209fae25422ff9459a6da382 100644 (file)
 #include <lttng/lttng-error.h>
 
 #include <inttypes.h>
+#include <iostream>
 #include <pthread.h>
 #include <stdlib.h>
 #include <string.h>
 
+namespace {
 /*
  * lttng_opt_abort_on_error: unset: -1, disabled: 0, enabled: 1.
  * Controlled by the LTTNG_ABORT_ON_ERROR environment variable.
  */
-static int lttng_opt_abort_on_error = -1;
+int lttng_opt_abort_on_error = -1;
 
 /* TLS variable that contains the time of one single log entry. */
 DEFINE_URCU_TLS(struct log_time, error_log_time);
+} /* namespace */
+
 DEFINE_URCU_TLS(const char *, logger_thread_name);
 
-const char *log_add_time(void)
+const char *log_add_time()
 {
        int ret;
        struct tm tm, *res;
@@ -449,3 +453,12 @@ void lttng_abort_on_error(void)
                abort();
        }
 }
+
+[[noreturn]] void
+lttng::logging::details::die_formatting_exception(const char *format,
+                                                 const std::exception& formatting_exception)
+{
+       std::cerr << "Error occurred while formatting logging message: msg=`" << format
+                 << "`: " << formatting_exception.what();
+       abort();
+}
This page took 0.023088 seconds and 4 git commands to generate.