Debug library

Dependents:   NetworkingCoreLib LwIPNetworking yeswecancoap lwip

Committer:
donatien
Date:
Thu May 24 15:33:14 2012 +0000
Revision:
0:3ac250c92185
Child:
1:bd1844de60f1
Child:
2:719e79a2291e
Initial Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:3ac250c92185 1 /* dbg.h */
donatien 0:3ac250c92185 2 /*
donatien 0:3ac250c92185 3 Copyright (C) 2012 ARM Limited.
donatien 0:3ac250c92185 4
donatien 0:3ac250c92185 5 Permission is hereby granted, free of charge, to any person obtaining a copy of
donatien 0:3ac250c92185 6 this software and associated documentation files (the "Software"), to deal in
donatien 0:3ac250c92185 7 the Software without restriction, including without limitation the rights to
donatien 0:3ac250c92185 8 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
donatien 0:3ac250c92185 9 of the Software, and to permit persons to whom the Software is furnished to do
donatien 0:3ac250c92185 10 so, subject to the following conditions:
donatien 0:3ac250c92185 11
donatien 0:3ac250c92185 12 The above copyright notice and this permission notice shall be included in all
donatien 0:3ac250c92185 13 copies or substantial portions of the Software.
donatien 0:3ac250c92185 14
donatien 0:3ac250c92185 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
donatien 0:3ac250c92185 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
donatien 0:3ac250c92185 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
donatien 0:3ac250c92185 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
donatien 0:3ac250c92185 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 0:3ac250c92185 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
donatien 0:3ac250c92185 21 SOFTWARE.
donatien 0:3ac250c92185 22 */
donatien 0:3ac250c92185 23
donatien 0:3ac250c92185 24 #ifndef DBG_H_
donatien 0:3ac250c92185 25 #define DBG_H_
donatien 0:3ac250c92185 26
donatien 0:3ac250c92185 27 #ifdef __cplusplus
donatien 0:3ac250c92185 28 extern "C" {
donatien 0:3ac250c92185 29 #endif
donatien 0:3ac250c92185 30
donatien 0:3ac250c92185 31
donatien 0:3ac250c92185 32 void debug_init(void);
donatien 0:3ac250c92185 33 void debug(int level, const char* module, int line, const char* fmt, ...);
donatien 0:3ac250c92185 34 void debug_error(const char* module, int line, int ret);
donatien 0:3ac250c92185 35
donatien 0:3ac250c92185 36 #if __DEBUG__
donatien 0:3ac250c92185 37 //#undef __DEBUG__
donatien 0:3ac250c92185 38 #endif
donatien 0:3ac250c92185 39 //#define __DEBUG__ 0
donatien 0:3ac250c92185 40
donatien 0:3ac250c92185 41 #define DBG_INIT() do{ debug_init(); }while(0)
donatien 0:3ac250c92185 42
donatien 0:3ac250c92185 43 #if __DEBUG__ > 0
donatien 0:3ac250c92185 44 #ifndef __MODULE__
donatien 0:3ac250c92185 45 #error "__MODULE__ must be defined"
donatien 0:3ac250c92185 46 #endif
donatien 0:3ac250c92185 47 #endif
donatien 0:3ac250c92185 48
donatien 0:3ac250c92185 49 #if __DEBUG__ >= 1
donatien 0:3ac250c92185 50 #define ERR(...) do{ debug(1, __MODULE__, __LINE__, __VA_ARGS__); }while(0)
donatien 0:3ac250c92185 51 #else
donatien 0:3ac250c92185 52 #define ERR(...) do{ }while(0)
donatien 0:3ac250c92185 53 #endif
donatien 0:3ac250c92185 54
donatien 0:3ac250c92185 55 #if __DEBUG__ >= 2
donatien 0:3ac250c92185 56 #define WARN(...) do{ debug(2, __MODULE__, __LINE__, __VA_ARGS__); }while(0)
donatien 0:3ac250c92185 57 #else
donatien 0:3ac250c92185 58 #define WARN(...) do{ }while(0)
donatien 0:3ac250c92185 59 #endif
donatien 0:3ac250c92185 60
donatien 0:3ac250c92185 61 #if __DEBUG__ >= 3
donatien 0:3ac250c92185 62 #define INFO(...) do{ debug(3, __MODULE__, __LINE__, __VA_ARGS__); }while(0)
donatien 0:3ac250c92185 63 #define CHECK(ret) do{ if(ret){ debug_error(__MODULE__, __LINE__, ret); } }while(0)
donatien 0:3ac250c92185 64 #else
donatien 0:3ac250c92185 65 #define INFO(...) do{ }while(0)
donatien 0:3ac250c92185 66 #define CHECK(ret) do{ }while(0)
donatien 0:3ac250c92185 67 #endif
donatien 0:3ac250c92185 68
donatien 0:3ac250c92185 69 #if __DEBUG__ >= 4
donatien 0:3ac250c92185 70 #define DBG(...) do{ debug(4, __MODULE__, __LINE__, __VA_ARGS__); }while(0)
donatien 0:3ac250c92185 71 #else
donatien 0:3ac250c92185 72 #define DBG(...) do{ }while(0)
donatien 0:3ac250c92185 73 #endif
donatien 0:3ac250c92185 74
donatien 0:3ac250c92185 75 #ifdef __cplusplus
donatien 0:3ac250c92185 76 }
donatien 0:3ac250c92185 77 #endif
donatien 0:3ac250c92185 78
donatien 0:3ac250c92185 79 #endif /* DBG_H_ */