X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Ferror.hpp;h=23d840c2daafcd3870ba4445708921c1ea3b93ad;hb=HEAD;hp=93616718f65dd89481492d39bf7ef0fe8ba1d261;hpb=003f455dab0204dd3f066ecdbea0470035f8181f;p=lttng-tools.git diff --git a/src/common/error.hpp b/src/common/error.hpp index 93616718f..66f38bf2e 100644 --- a/src/common/error.hpp +++ b/src/common/error.hpp @@ -46,7 +46,8 @@ struct log_time { /* Format: 00:00:00.000000000 plus NULL byte. */ char str[19]; }; -extern DECLARE_URCU_TLS(const char *, logger_thread_name); + +extern thread_local const char *logger_thread_name; extern int lttng_opt_quiet; extern int lttng_opt_verbose; @@ -159,7 +160,7 @@ static inline void __lttng_print_check_abort(enum lttng_error_level type) msg " - %s [%s]: " fmt " (in %s() at " __FILE__ \ ":" XSTR(__LINE__) ")\n", \ log_add_time(), \ - URCU_TLS(logger_thread_name) ?: generic_name, \ + logger_thread_name ?: generic_name, \ ##args, \ __func__); \ } \ @@ -179,7 +180,7 @@ static inline void __lttng_print_check_abort(enum lttng_error_level type) __lttng_print(type, \ msg " - %s [%s]: " fmt "\n", \ log_add_time(), \ - URCU_TLS(logger_thread_name) ?: generic_name, \ + logger_thread_name ?: generic_name, \ ##args); \ } \ } while (0) @@ -225,6 +226,7 @@ static inline void __lttng_print_check_abort(enum lttng_error_level type) } while (0); #define _PERROR(fmt, args...) _ERRMSG("PERROR", PRINT_ERR, fmt, ##args) +#define _PWARN(fmt, args...) _ERRMSG("PWARN", PRINT_WARN, fmt, ##args) #if !defined(__GLIBC__) || \ ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)) @@ -238,11 +240,17 @@ static inline void __lttng_print_check_abort(enum lttng_error_level type) strerror_r(errno, _perror_buf, sizeof(_perror_buf)); \ _PERROR(call ": %s", ##args, _perror_buf); \ } while (0); + +#define PWARN(call, args...) \ + do { \ + char _perror_buf[200]; \ + strerror_r(errno, _perror_buf, sizeof(_perror_buf)); \ + _PWARN(call ": %s", ##args, _perror_buf); \ + } while (0); #else /* * Version using GNU strerror_r, for linux with appropriate defines. */ -const char *error_get_str(int32_t code); #define PERROR(call, args...) \ do { \ char *_perror_buf; \ @@ -250,8 +258,17 @@ const char *error_get_str(int32_t code); _perror_buf = strerror_r(errno, _perror_tmp, sizeof(_perror_tmp)); \ _PERROR(call ": %s", ##args, _perror_buf); \ } while (0); +#define PWARN(call, args...) \ + do { \ + char *_perror_buf; \ + char _perror_tmp[200]; \ + _perror_buf = strerror_r(errno, _perror_tmp, sizeof(_perror_tmp)); \ + _PWARN(call ": %s", ##args, _perror_buf); \ + } while (0); #endif +const char *error_get_str(int32_t code); + namespace lttng { namespace logging { namespace details { @@ -264,7 +281,7 @@ namespace details { #define DBG_FMT(format_str, args...) \ do { \ try { \ - DBG("%s", fmt::format(format_str, ##args).c_str()); \ + DBG("%s", lttng::format(format_str, ##args).c_str()); \ } catch (const std::exception& _formatting_exception) { \ lttng::logging::details::die_formatting_exception(format_str, \ _formatting_exception); \ @@ -274,7 +291,7 @@ namespace details { #define WARN_FMT(format_str, args...) \ do { \ try { \ - WARN("%s", fmt::format(format_str, ##args).c_str()); \ + WARN("%s", lttng::format(format_str, ##args).c_str()); \ } catch (const std::exception& _formatting_exception) { \ lttng::logging::details::die_formatting_exception(format_str, \ _formatting_exception); \ @@ -284,7 +301,7 @@ namespace details { #define ERR_FMT(format_str, args...) \ do { \ try { \ - ERR("%s", fmt::format(format_str, ##args).c_str()); \ + ERR("%s", lttng::format(format_str, ##args).c_str()); \ } catch (const std::exception& _formatting_exception) { \ lttng::logging::details::die_formatting_exception(format_str, \ _formatting_exception); \