1 /* 2 * Author: Harry van Haaren 2013 3 * harryhaaren@gmail.com 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (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 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef LUPPP_DEBUG_HXX 20 #define LUPPP_DEBUG_HXX 21 22 #include <stdio.h> 23 #include <stdarg.h> 24 25 /* Example usage 26 LUPPP_NOTE( "%s", "MessageHere" ); 27 LUPPP_WARN( "%s", "MessageHere" ); 28 LUPPP_KILL( "%s", "MessageHere" ); 29 */ 30 31 enum DEBUG_LEVEL { 32 DEBUG_LEVEL_NOTE = 0, 33 DEBUG_LEVEL_WARN, 34 DEBUG_LEVEL_ERROR, 35 DEBUG_LEVEL_TEST 36 }; 37 38 void luppp_debug( int warnLevel, const char* name, const char* file, const char* func, int line, 39 const char* format = 0, ... ); 40 41 42 #define LUPPP_DSP( format, args... ) luppp_debug( DEBUG_LEVEL_NOTE, " DSP ", "", "", 0, format, ## args ) 43 44 #define LUPPP_NOTE( format, args... ) luppp_debug( DEBUG_LEVEL_NOTE, NAME, __FILE__, __FUNCTION__, __LINE__, format, ## args ) 45 #define LUPPP_WARN( format, args... ) luppp_debug( DEBUG_LEVEL_WARN, NAME, __FILE__, __FUNCTION__, __LINE__, format, ## args ) 46 #define LUPPP_ERROR( format, args... ) luppp_debug( DEBUG_LEVEL_ERROR, NAME, __FILE__, __FUNCTION__, __LINE__, format, ## args ) 47 48 // only gets printed if #definde BUILD_TESTS 49 #define LUPPP_PRINT_TEST( format, args... ) luppp_debug( DEBUG_LEVEL_DEBUG_ONLY, NAME, __FILE__, __FUNCTION__, __LINE__, format, ## args ) 50 51 #endif 52 53