egg-debug.h 2.61 KB
Newer Older
1 2
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 *
3
 * Copyright (C) 2007-2009 Richard Hughes <richard@hughsie.com>
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * Licensed under the GNU General Public License Version 2
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 21
 */

22 23
#ifndef __EGG_DEBUG_H
#define __EGG_DEBUG_H
24 25 26 27 28 29 30 31

#include <stdarg.h>
#include <glib.h>

G_BEGIN_DECLS

#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/**
32
 * egg_debug:
33 34 35
 *
 * Non critical debugging
 */
36
#define egg_debug(...) egg_debug_real (__func__, __FILE__, __LINE__, __VA_ARGS__)
37 38

/**
39
 * egg_warning:
40 41 42
 *
 * Important debugging
 */
43
#define egg_warning(...) egg_warning_real (__func__, __FILE__, __LINE__, __VA_ARGS__)
44 45

/**
46
 * egg_error:
47 48 49
 *
 * Critical debugging, with exit
 */
50
#define egg_error(...) egg_error_real (__func__, __FILE__, __LINE__, __VA_ARGS__)
51 52

#elif defined(__GNUC__) && __GNUC__ >= 3
53 54 55
#define egg_debug(...) egg_debug_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#define egg_warning(...) egg_warning_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#define egg_error(...) egg_error_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
56
#else
57 58 59
#define egg_debug(...)
#define egg_warning(...)
#define egg_error(...)
60 61
#endif

62 63 64 65 66 67 68
gboolean	 egg_debug_init			(gint		*argc,
						 gchar		***argv);
GOptionGroup	*egg_debug_get_option_group	(void);
gboolean	 egg_debug_is_verbose		(void);
void		 egg_debug_backtrace		(void);
void		 egg_debug_set_log_filename	(const gchar	*filename);
void		 egg_debug_real			(const gchar	*func,
69
						 const gchar	*file,
70
						 gint		 line,
71
						 const gchar	*format, ...) __attribute__((format (printf,4,5)));
72
void		 egg_warning_real		(const gchar	*func,
73
						 const gchar	*file,
74
						 gint		 line,
75
						 const gchar	*format, ...) __attribute__((format (printf,4,5)));
76
void		 egg_error_real			(const gchar	*func,
77
						 const gchar	*file,
78
						 gint		 line,
Richard Hughes's avatar
Richard Hughes committed
79
						 const gchar	*format, ...) G_GNUC_NORETURN __attribute__((format (printf,4,5)));
80 81 82

G_END_DECLS

83
#endif /* __EGG_DEBUG_H */