Added HTTP API to C027_Support library.
Fork of C027_Support by
Revision 117:74e4e0109a9e, committed 2015-01-22
- Comitter:
- mazgch
- Date:
- Thu Jan 22 08:02:55 2015 +0000
- Parent:
- 116:709a6386e685
- Child:
- 118:c2c4b6b421c8
- Child:
- 121:8da935c2c08c
- Commit message:
- improve debug api
Changed in this revision
MDM.cpp | Show annotated file Show diff for this revision Revisions of this file |
MDM.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MDM.cpp Wed Dec 17 11:35:07 2014 +0000 +++ b/MDM.cpp Thu Jan 22 08:02:55 2015 +0000 @@ -62,10 +62,24 @@ ::printf("\"\r\n"); } - #define ERROR(...) (_debugLevel < 0) ? : ::printf(RED), ::printf(__VA_ARGS__), ::printf(DEF) - #define TEST(...) ::printf(CYA), ::printf(__VA_ARGS__), ::printf(DEF) - #define INFO(...) (_debugLevel < 1) ? : ::printf(GRE), ::printf(__VA_ARGS__), ::printf(DEF) - #define TRACE(...) (_debugLevel < 2) ? : ::printf(__VA_ARGS__) +void MDMParser::_debugPrint(int level, const char* color, const char* format, ...) +{ + if (_debugLevel >= level) + { + ::printf("_debugPrint %d %d\r\n", _debugLevel, level); + va_list args; + va_start (args, format); + if (color) ::printf(color); + ::vprintf(format, args); + if (color) ::printf(DEF); + va_end (args); + } +} + + #define ERROR(...) _debugPrint(0, RED, __VA_ARGS__) + #define INFO(...) _debugPrint(1, GRE, __VA_ARGS__) + #define TRACE(...) _debugPrint(2, DEF, __VA_ARGS__) + #define TEST(...) _debugPrint(3, CYA, __VA_ARGS__) #else @@ -1378,7 +1392,8 @@ bool MDMParser::setDebug(int level) { #ifdef MDM_DEBUG - if ((_debugLevel >= 0) && (level >= 0)) { + if ((_debugLevel >= -1) && (level >= -1) && + (_debugLevel <= 3) && (level <= 3)) { _debugLevel = level; return true; }
--- a/MDM.h Wed Dec 17 11:35:07 2014 +0000 +++ b/MDM.h Thu Jan 22 08:02:55 2015 +0000 @@ -322,7 +322,7 @@ // ---------------------------------------------------------------- /*! Set the debug level - \param level 0 = OFF, 1 = INFO(default), 2 = TRACE, 3 = ATCMD + \param level -1 = OFF, 0 = ERROR, 1 = INFO(default), 2 = TRACE, 3 = ATCMD,TEST \return true if successful, false not possible */ bool setDebug(int level); @@ -558,6 +558,7 @@ #ifdef MDM_DEBUG int _debugLevel; Timer _debugTime; + void _debugPrint(int level, const char* color, const char* format, ...); #endif };