Remove libustctl and libustcomm
[lttng-tools.git] / include / lttngerr.h
CommitLineData
826d496d
MD
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
fac6795d
DG
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.
fac6795d
DG
17 */
18
19#ifndef _LTTNGERR_H
20#define _LTTNGERR_H
21
22#include <errno.h>
d738ac16 23#include <stdio.h>
fac6795d 24
57d0d501
DG
25/* Stringify the expansion of a define */
26#define XSTR(d) STR(d)
27#define STR(s) #s
28
fac6795d
DG
29extern int opt_quiet;
30extern int opt_verbose;
31
32enum __lttng_print_type {
33 PRINT_ERR,
34 PRINT_WARN,
35 PRINT_BUG,
36 PRINT_DBG,
37 PRINT_MSG,
38};
39
40/*
41 * __lttng_print
42 *
3ce7388b
DG
43 * Macro for printing message depending on
44 * command line option and verbosity.
fac6795d 45 */
3ce7388b
DG
46#define __lttng_print(type, fmt, args...) \
47 do { \
48 if (opt_quiet == 0) { \
49 if (type == PRINT_MSG || (opt_verbose && type == PRINT_DBG)) { \
50 fprintf(stdout, fmt, ## args); \
51 } else if (type != PRINT_MSG && type != PRINT_DBG) { \
52 fprintf(stderr, fmt, ## args); \
53 } \
54 } \
55 } while (0);
fac6795d
DG
56
57#define MSG(fmt, args...) __lttng_print(PRINT_MSG, fmt "\n", ## args)
58#define ERR(fmt, args...) __lttng_print(PRINT_ERR, "Error: " fmt "\n", ## args)
59#define WARN(fmt, args...) __lttng_print(PRINT_WARN, "Warning: " fmt "\n", ## args)
60#define BUG(fmt, args...) __lttng_print(PRINT_BUG, "BUG: " fmt "\n", ## args)
57d0d501 61#define DBG(fmt, args...) __lttng_print(PRINT_DBG, "DEBUG: " fmt " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__)
fac6795d
DG
62
63#endif /* _LTTNGERR_H */
This page took 0.027125 seconds and 5 git commands to generate.