Debug library
Dependents: NetworkingCoreLib LwIPNetworking yeswecancoap lwip
dbg.h
00001 /* dbg.h */ 00002 /* Copyright (C) 2012 mbed.org, MIT License 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00005 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00006 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00007 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00008 * furnished to do so, subject to the following conditions: 00009 * 00010 * The above copyright notice and this permission notice shall be included in all copies or 00011 * substantial portions of the Software. 00012 * 00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00014 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00015 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00016 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00018 */ 00019 00020 #ifndef DBG_H_ 00021 #define DBG_H_ 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 00028 void debug_init(void); 00029 void debug(int level, const char* module, int line, const char* fmt, ...); 00030 void debug_set_newline(const char* newline); 00031 void debug_error(const char* module, int line, int ret); 00032 void debug_exact(const char* fmt, ...); 00033 00034 #define DBG_INIT() do{ debug_init(); }while(0) 00035 00036 #define DBG_SET_NEWLINE( x ) do{ debug_set_newline(x); }while(0) 00037 00038 #if __DEBUG__ > 0 00039 #ifndef __MODULE__ 00040 #error "__MODULE__ must be defined" 00041 #endif 00042 #endif 00043 00044 #if __DEBUG__ >= 1 00045 #define ERR(...) do{ debug(1, __MODULE__, __LINE__, __VA_ARGS__); }while(0) 00046 #else 00047 #define ERR(...) do{ }while(0) 00048 #endif 00049 00050 #if __DEBUG__ >= 2 00051 #define WARN(...) do{ debug(2, __MODULE__, __LINE__, __VA_ARGS__); }while(0) 00052 #else 00053 #define WARN(...) do{ }while(0) 00054 #endif 00055 00056 #if __DEBUG__ >= 3 00057 #define INFO(...) do{ debug(3, __MODULE__, __LINE__, __VA_ARGS__); }while(0) 00058 #define CHECK(ret) do{ if(ret){ debug_error(__MODULE__, __LINE__, ret); } }while(0) 00059 #else 00060 #define INFO(...) do{ }while(0) 00061 #define CHECK(ret) do{ }while(0) 00062 #endif 00063 00064 #if __DEBUG__ >= 4 00065 #define DBG(...) do{ debug(4, __MODULE__, __LINE__, __VA_ARGS__); }while(0) 00066 #define DBGX(...) do{ debug_exact(__VA_ARGS__); }while(0) 00067 #else 00068 #define DBG(...) do{ }while(0) 00069 #define DBGX(...) do{ }while(0) 00070 #endif 00071 00072 #ifdef __cplusplus 00073 } 00074 #endif 00075 00076 #endif /* DBG_H_ */
Generated on Thu Jul 14 2022 07:10:37 by 1.7.2