2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; only version 2
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 /* Stringify the expansion of a define */
26 #define XSTR(d) STR(d)
30 extern int opt_verbose
;
33 #define PRINT_WARN 0x2
36 #define PRINT_DBG 0x10
37 #define PRINT_DBG2 0x20
38 #define PRINT_DBG3 0x30
41 * Macro for printing message depending on command line option and verbosity.
43 #define __lttng_print(type, fmt, args...) \
45 if (opt_quiet == 0) { \
46 if (type == PRINT_MSG || \
47 ((type & PRINT_DBG) && opt_verbose == 1) || \
48 ((type & (PRINT_DBG | PRINT_DBG2)) && \
49 opt_verbose == 2) || \
50 ((type & (PRINT_DBG | PRINT_DBG2 | PRINT_DBG3)) && \
51 opt_verbose == 3)) { \
52 fprintf(stderr, fmt, ## args); \
53 } else if (type & (PRINT_ERR | PRINT_WARN | PRINT_BUG)) { \
54 fprintf(stderr, fmt, ## args); \
59 #define MSG(fmt, args...) \
60 __lttng_print(PRINT_MSG, fmt "\n", ## args)
61 #define ERR(fmt, args...) \
62 __lttng_print(PRINT_ERR, "Error: " fmt "\n", ## args)
63 #define WARN(fmt, args...) \
64 __lttng_print(PRINT_WARN, "Warning: " fmt "\n", ## args)
65 #define BUG(fmt, args...) \
66 __lttng_print(PRINT_BUG, "BUG: " fmt "\n", ## args)
68 /* Three level of debug. Use -v, -vv or -vvv for the levels */
69 #define DBG(fmt, args...) __lttng_print(PRINT_DBG, "DEBUG1: " fmt \
70 " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__)
71 #define DBG2(fmt, args...) __lttng_print(PRINT_DBG2, "DEBUG2: " fmt \
72 " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__)
73 #define DBG3(fmt, args...) __lttng_print(PRINT_DBG3, "DEBUG3: " fmt \
74 " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__)
76 #define _PERROR(fmt, args...) \
77 __lttng_print(PRINT_ERR, "perror " fmt "\n", ## args)
79 #define PERROR(call, args...) \
83 buf = strerror_r(errno, tmp, sizeof(tmp)); \
84 _PERROR(call ": %s", ## args, buf); \
87 #endif /* _LTTNGERR_H */
This page took 0.033887 seconds and 4 git commands to generate.