X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Ferror.h;h=33a299c4e4952e3882bdbc457e0bd55c042982bc;hp=ad6113fa7494599cebcdb81b0a3bd7c2ef4956a0;hb=7ca172c15891d4ff3f711dcc05f991fd2c094bc7;hpb=ab530aafeeff0dc4ae4b001bb3994bfaf2d5e55f diff --git a/src/common/error.h b/src/common/error.h index ad6113fa7..33a299c4e 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -1,18 +1,8 @@ /* - * Copyright (C) 2011 - David Goulet + * Copyright (C) 2011 David Goulet * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef _ERROR_H @@ -24,7 +14,7 @@ #include #include #include -#include +#include #ifndef _GNU_SOURCE #error "lttng-tools error.h needs _GNU_SOURCE" @@ -48,8 +38,8 @@ * every time a log is fired. */ struct log_time { - /* Format: 00:00:00.000000 plus NULL byte. */ - char str[16]; + /* Format: 00:00:00.000000000 plus NULL byte. */ + char str[19]; }; extern DECLARE_URCU_TLS(struct log_time, error_log_time); @@ -58,7 +48,7 @@ extern int lttng_opt_verbose; extern int lttng_opt_mi; /* Error type. */ -enum lttng_error_type { +enum lttng_error_level { PRINT_ERR = 0, PRINT_BUG = 1, PRINT_WARN = 2, @@ -68,7 +58,7 @@ enum lttng_error_type { PRINT_DBG3 = 6, }; -static inline bool __lttng_print_check_opt(enum lttng_error_type type) +static inline bool __lttng_print_check_opt(enum lttng_error_level type) { /* lttng_opt_mi and lttng_opt_quiet. */ switch (type) { @@ -117,7 +107,7 @@ static inline bool __lttng_print_check_opt(enum lttng_error_type type) void lttng_abort_on_error(void); -static inline void __lttng_print_check_abort(enum lttng_error_type type) +static inline void __lttng_print_check_abort(enum lttng_error_level type) { switch (type) { case PRINT_DBG3: @@ -151,7 +141,11 @@ static inline void __lttng_print_check_abort(enum lttng_error_type type) /* Three level of debug. Use -v, -vv or -vvv for the levels */ #define _ERRMSG(msg, type, fmt, args...) __lttng_print(type, msg \ " - %s [%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" XSTR(__LINE__) ")\n", \ - log_add_time(), (long) getpid(), (long) gettid(), ## args, __func__) + log_add_time(), (long) getpid(), (long) lttng_gettid(), ## args, __func__) + +#define _ERRMSG_NO_LOC(msg, type, fmt, args...) __lttng_print(type, msg \ + " - %s [%ld/%ld]: " fmt "\n", \ + log_add_time(), (long) getpid(), (long) lttng_gettid(), ## args) #define MSG(fmt, args...) \ __lttng_print(PRINT_MSG, fmt "\n", ## args) @@ -165,6 +159,7 @@ static inline void __lttng_print_check_abort(enum lttng_error_type type) #define BUG(fmt, args...) _ERRMSG("BUG", PRINT_BUG, fmt, ## args) #define DBG(fmt, args...) _ERRMSG("DEBUG1", PRINT_DBG, fmt, ## args) +#define DBG_NO_LOC(fmt, args...) _ERRMSG_NO_LOC("DEBUG1", PRINT_DBG, fmt, ## args) #define DBG2(fmt, args...) _ERRMSG("DEBUG2", PRINT_DBG2, fmt, ## args) #define DBG3(fmt, args...) _ERRMSG("DEBUG3", PRINT_DBG3, fmt, ## args) #define LOG(type, fmt, args...) \ @@ -198,7 +193,7 @@ static inline void __lttng_print_check_abort(enum lttng_error_type type) #define _PERROR(fmt, args...) _ERRMSG("PERROR", PRINT_ERR, fmt, ## args) -#if !defined(__linux__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)) +#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)) /* * Version using XSI strerror_r. @@ -229,6 +224,6 @@ const char *error_get_str(int32_t code); * the caller. On error, an empty string is returned thus no time will be * printed in the log. */ -const char *log_add_time(); +const char *log_add_time(void); #endif /* _ERROR_H */