pengfei wu
/
ESP8266Program
For test
Diff: log.h
- Revision:
- 15:f5682fb5b315
- Parent:
- 14:40b1decf03f3
- Child:
- 16:e184ebcd5896
--- a/log.h Tue Feb 03 09:10:16 2015 +0000 +++ b/log.h Tue Feb 03 10:50:05 2015 +0000 @@ -3,26 +3,30 @@ #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 (0) +#define LOG_OUTPUT_WARN (0) +#define LOG_OUTPUT_INFO (0) +#define LOG_OUTPUT_DEBUG (0) +#define LOG_OUTPUT_VERBOSE (0) -#define LOG_OUTPUT_ERROR_PREFIX (0) -#define LOG_OUTPUT_WARN_PREFIX (0) +#define LOG_OUTPUT_ERROR_PREFIX (1) +#define LOG_OUTPUT_WARN_PREFIX (1) +#define LOG_OUTPUT_INFO_PREFIX (0) #define LOG_OUTPUT_DEBUG_PREFIX (0) -#define LOG_OUTPUT_INFO_PREFIX (0) #define LOG_OUTPUT_VERBOSE_PREFIX (0) +extern Serial pc; + +#define log_out pc.printf + #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");\ + log_out("[LOG Error:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ + log_out(fmt, ##args);\ + log_out("\r\n");\ }\ } while(0) @@ -31,9 +35,9 @@ if (LOG_OUTPUT_WARN)\ {\ if(LOG_OUTPUT_WARN_PREFIX)\ - printf("[LOG Warn:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ - printf(fmt, ##args);\ - printf("\r\n");\ + log_out("[LOG Warn:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ + log_out(fmt, ##args);\ + log_out("\r\n");\ }\ } while(0) @@ -42,9 +46,9 @@ if (LOG_OUTPUT_DEBUG)\ {\ if (LOG_OUTPUT_DEBUG_PREFIX)\ - printf("[LOG Debug:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ - printf(fmt, ##args);\ - printf("\r\n");\ + log_out("[LOG Debug:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ + log_out(fmt, ##args);\ + log_out("\r\n");\ }\ } while(0) @@ -53,9 +57,9 @@ if (LOG_OUTPUT_INFO)\ {\ if (LOG_OUTPUT_INFO_PREFIX)\ - printf("[LOG Info:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ - printf(fmt, ##args);\ - printf("\r\n");\ + log_out("[LOG Info:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ + log_out(fmt, ##args);\ + log_out("\r\n");\ }\ } while(0) @@ -65,9 +69,9 @@ if (LOG_OUTPUT_VERBOSE)\ {\ if (LOG_OUTPUT_VERBOSE_PREFIX)\ - printf("[LOG Verbose:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ - printf(fmt, ##args);\ - printf("\r\n");\ + log_out("[LOG Verbose:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\ + log_out(fmt, ##args);\ + log_out("\r\n");\ }\ } while(0)