pengfei wu
/
ESP8266Program
For test
Diff: log.h
- Revision:
- 14:40b1decf03f3
- Child:
- 15:f5682fb5b315
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/log.h Tue Feb 03 09:10:16 2015 +0000 @@ -0,0 +1,75 @@ +#ifndef __DEBUG_H__ +#define __DEBUG_H__ + +#include "mbed.h" + +#define LOG_OUTPUT_ERROR (1) +#define LOG_OUTPUT_WARN (1) +#define LOG_OUTPUT_INFO (1) +#define LOG_OUTPUT_VERBOSE (1) +#define LOG_OUTPUT_DEBUG (1) + +#define LOG_OUTPUT_ERROR_PREFIX (0) +#define LOG_OUTPUT_WARN_PREFIX (0) +#define LOG_OUTPUT_DEBUG_PREFIX (0) +#define LOG_OUTPUT_INFO_PREFIX (0) +#define LOG_OUTPUT_VERBOSE_PREFIX (0) + +#define logError(fmt, args...)\ + do {\ + if (LOG_OUTPUT_ERROR)\ + {\ + if(LOG_OUTPUT_ERROR_PREFIX)\ + printf("[LOG Error:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ + printf(fmt, ##args);\ + printf("\r\n");\ + }\ + } while(0) + +#define logWarn(fmt, args...)\ + do {\ + if (LOG_OUTPUT_WARN)\ + {\ + if(LOG_OUTPUT_WARN_PREFIX)\ + printf("[LOG Warn:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ + printf(fmt, ##args);\ + printf("\r\n");\ + }\ + } while(0) + +#define logDebug(fmt, args...)\ + do {\ + if (LOG_OUTPUT_DEBUG)\ + {\ + if (LOG_OUTPUT_DEBUG_PREFIX)\ + printf("[LOG Debug:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ + printf(fmt, ##args);\ + printf("\r\n");\ + }\ + } while(0) + +#define logInfo(fmt, args...)\ + do {\ + if (LOG_OUTPUT_INFO)\ + {\ + if (LOG_OUTPUT_INFO_PREFIX)\ + printf("[LOG Info:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ + printf(fmt, ##args);\ + printf("\r\n");\ + }\ + } while(0) + + +#define logVerbose(fmt, args...)\ + do {\ + if (LOG_OUTPUT_VERBOSE)\ + {\ + if (LOG_OUTPUT_VERBOSE_PREFIX)\ + printf("[LOG Verbose:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ + printf(fmt, ##args);\ + printf("\r\n");\ + }\ + } while(0) + + +#endif /* #ifndef __DEBUG_H__ */ \ No newline at end of file