Add missing stdio header for fprintf
[lttng-tools.git] / include / lttngerr.h
1 /*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
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; either version 2
7 * of the License, or (at your option) any later version.
8 *
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.
13 *
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.
17 */
18
19 #ifndef _LTTNGERR_H
20 #define _LTTNGERR_H
21
22 #include <errno.h>
23 #include <stdio.h>
24
25 extern int opt_quiet;
26 extern int opt_verbose;
27
28 enum __lttng_print_type {
29 PRINT_ERR,
30 PRINT_WARN,
31 PRINT_BUG,
32 PRINT_DBG,
33 PRINT_MSG,
34 };
35
36 /*
37 * __lttng_print
38 *
39 * Macro for printing message depending on
40 * command line option and verbosity.
41 */
42 #define __lttng_print(type, fmt, args...) \
43 do { \
44 if (opt_quiet == 0) { \
45 if (type == PRINT_MSG || (opt_verbose && type == PRINT_DBG)) { \
46 fprintf(stdout, fmt, ## args); \
47 } else if (type != PRINT_MSG && type != PRINT_DBG) { \
48 fprintf(stderr, fmt, ## args); \
49 } \
50 } \
51 } while (0);
52
53 #define MSG(fmt, args...) __lttng_print(PRINT_MSG, fmt "\n", ## args)
54 #define ERR(fmt, args...) __lttng_print(PRINT_ERR, "Error: " fmt "\n", ## args)
55 #define WARN(fmt, args...) __lttng_print(PRINT_WARN, "Warning: " fmt "\n", ## args)
56 #define BUG(fmt, args...) __lttng_print(PRINT_BUG, "BUG: " fmt "\n", ## args)
57 #define DBG(fmt, args...) __lttng_print(PRINT_DBG, "DEBUG: " fmt "\n", ## args)
58
59 #endif /* _LTTNGERR_H */
This page took 0.031284 seconds and 5 git commands to generate.