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