1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 2 /* 3 * Copyright (C) 2006 Brent Smith <gnome@nextreality.net> 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License as 7 * published by the Free Software Foundation; either version 2 of the 8 * License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public 16 * License along with this program; if not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef __YELP_DEBUG_H__ 20 #define __YELP_DEBUG_H__ 21 22 G_BEGIN_DECLS 23 24 #include <unistd.h> 25 #include <glib.h> 26 27 typedef enum { 28 DB_FUNCTION = 1 << 0, 29 DB_ARG = 1 << 1, 30 DB_PROFILE = 1 << 2, 31 DB_LOG = 1 << 3, 32 DB_INFO = 1 << 4, 33 DB_DEBUG = 1 << 5, 34 DB_WARN = 1 << 6, 35 DB_ERROR = 1 << 7, 36 DB_ALL = 1 << 8 37 } YelpDebugEnums; 38 39 #if defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L 40 # if __GNUC__ >= 2 41 # define __func__ __FUNCTION__ 42 # else 43 # define __func__ "<unknown>" 44 # endif 45 #endif 46 47 /* __VA_ARGS__ is C99 compliant but may not work on older versions of cpp, 48 * so we provide a fallback */ 49 #ifdef YELP_DEBUG 50 # if defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L 51 # define debug_print(format, args...) yelp_debug (__FILE__, __LINE__, __func__, format, args) 52 # else 53 # define debug_print(format, ...) yelp_debug (__FILE__, __LINE__, __func__, format, __VA_ARGS__) 54 # endif 55 #else 56 # if defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L 57 # define debug_print(format, args...) 58 # else 59 # define debug_print(format, ...) 60 # endif 61 #endif 62 63 #ifdef YELP_DEBUG 64 # define d(x) x 65 #else 66 # define d(x) 67 #endif 68 69 G_GNUC_INTERNAL 70 void yelp_debug (const gchar *file, guint line, 71 const gchar *function, guint flags, 72 const gchar *format, ...) G_GNUC_PRINTF (5, 6); 73 74 G_END_DECLS 75 76 #endif /* __YELP_DEBUG_H__ */ 77