Made on Kubuntu
00001 // Copyright (C) 2009-2010 Ferdinand Majerech 00002 // This file is part of MiniINI 00003 // For conditions of distribution and use, see copyright notice in LICENSE.txt 00004 00005 #ifndef LOG_H_INCLUDED 00006 #define LOG_H_INCLUDED 00007 00008 #include <cstdio> 00009 #include "typedefs.h" 00010 #include "globals.h" 00011 00012 namespace miniini_private 00013 { 00014 00016 00017 //Ptr to the logging function 00018 extern void(* __Log)(const char * const); 00019 00020 #ifdef MINIINI_DEBUG 00021 00022 #define MINIINI_LOGBUFSIZE 1024 00023 00024 extern c log_buf [MINIINI_LOGBUFSIZE]; 00025 00026 #define MINIINI_LOG_BASE(...)\ 00027 snprintf(miniini_private::log_buf, MINIINI_LOGBUFSIZE, __VA_ARGS__);\ 00028 miniini_private::__Log(miniini_private::log_buf); 00029 00030 #define MINIINI_WARNING(...) \ 00031 {\ 00032 if(miniini_private::__Log)\ 00033 {\ 00034 miniini_private::__Log("MiniINI WARNING:");\ 00035 MINIINI_LOG_BASE(__VA_ARGS__);\ 00036 }\ 00037 } 00038 00039 #define MINIINI_ERROR(...) \ 00040 {\ 00041 if(miniini_private::__Log)\ 00042 {\ 00043 miniini_private::__Log("MiniINI ERROR:");\ 00044 MINIINI_LOG_BASE(__VA_ARGS__);\ 00045 }\ 00046 } 00047 00048 #define MINIINI_LOG(...) \ 00049 {\ 00050 if(__Log)\ 00051 {\ 00052 miniini_private::__Log("MiniINI:");\ 00053 MINIINI_LOG_BASE(__VA_ARGS__);\ 00054 }\ 00055 } 00056 00057 00058 #else 00059 00060 #define MINIINI_WARNING(...) ((void)0); 00061 00062 #define MINIINI_ERROR(...) ((void)0); 00063 00064 #define MINIINI_LOG(...) ((void)0); 00065 00066 #endif 00067 00069 00070 } 00071 00075 void INILogCallback(void(* callback)(const char * const)); 00076 00077 #endif