lomoco_debug.h
Go to the documentation of this file.00001 /* 00002 * lomoco - Logitech Mouse Control for Linux 00003 * 00004 * debug.h form XQF - Quake server browser and launcher 00005 * Copyright (C) 1998-2000 Roman Pozlevich <roma@botik.ru> 00006 * Copyright (c) 2006 by Andreas Schneider <mail@cynapses.org> 00007 * 00008 * This program is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU General Public License 00010 * as published by the Free Software Foundation; either version 2 00011 * of the License, or (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software Foundation, 00020 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00021 * 00022 * vim: ts=2 sw=2 et cindent 00023 */ 00024 00025 #ifndef _LOMOCO_DEBUG_H 00026 #define _LOMOCO_DEBUG_H 00027 00028 #include <libgen.h> 00029 00030 /** 00031 * @def DEFAULT_DEBUG_LEVEL. 00032 * A macro for the default debug level. 00033 */ 00034 #define DEFAULT_DEBUG_LEVEL 0 00035 00036 /** 00037 * @def LOMOCO_DEBUG. 00038 * A macro that prints the given debug message depending on the debug level. 00039 */ 00040 #define LOMOCO_DEBUG(level,fmt,rest...) \ 00041 if (level <= lomoco_get_debug_level()) \ 00042 lomoco_debug_int(basename(__FILE__),__LINE__,__FUNCTION__,level,0,fmt,##rest) 00043 00044 /** 00045 * @def LOMOCO_INFORMAL. 00046 * A macro that prints the given informal message. 00047 */ 00048 #define LOMOCO_INFORMAL(fmt,rest...) \ 00049 lomoco_debug_int(basename(__FILE__),__LINE__,__FUNCTION__,-1,0,fmt,##rest) 00050 00051 /** 00052 * @def LOMOCO_WARNING. 00053 * A macro that prints the given warning message. 00054 */ 00055 #define LOMOCO_WARNING(fmt,rest...) \ 00056 lomoco_debug_int(basename(__FILE__),__LINE__,__FUNCTION__,-2,0,fmt,##rest) 00057 00058 /** 00059 * @def LOMOCO_ERROR. 00060 * A macro that prints the given error message. 00061 */ 00062 #define LOMOCO_ERROR(fmt,rest...) \ 00063 lomoco_debug_int(basename(__FILE__),__LINE__,__FUNCTION__,-3,0,fmt,##rest) 00064 00065 /** 00066 * @def LOMOCO_ERRNO 00067 * A macro that prints the given error message depending on the error number. 00068 */ 00069 #define LOMOCO_ERRNO(err,fmt,rest...) \ 00070 lomoco_debug_int(basename(__FILE__),__LINE__,__FUNCTION__,-4,err,fmt,##rest) 00071 00072 void lomoco_debug_int(const char* file, int line, const char* function, int level, int err, const char* fmt, ...); 00073 void lomoco_debug_cmd(int, char *[], char *, ...); 00074 void lomoco_set_debug_level (int); 00075 inline int lomoco_get_debug_level (void); 00076 00077 int lomoco_debug_increase_indent(void); 00078 int lomoco_debug_decrease_indent(void); 00079 00080 #endif /* _LOMOCO_DEBUG_H */ 00081