Provide an easy-to-use way to manipulate ESP8266.

Dependencies:   ArduinoAPI

Fork of WeeESP8266 by ITEAD STUDIO

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers log.h Source File

log.h

00001 #ifndef __DEBUG_H__
00002 #define __DEBUG_H__
00003 
00004 #include "mbed.h"
00005 
00006 #define LOG_OUTPUT_ERROR              (0)
00007 #define LOG_OUTPUT_WARN               (0)
00008 #define LOG_OUTPUT_INFO               (0)
00009 #define LOG_OUTPUT_DEBUG              (0)
00010 #define LOG_OUTPUT_VERBOSE            (0)
00011 
00012 #define LOG_OUTPUT_ERROR_PREFIX       (1)
00013 #define LOG_OUTPUT_WARN_PREFIX        (1)
00014 #define LOG_OUTPUT_INFO_PREFIX        (0)
00015 #define LOG_OUTPUT_DEBUG_PREFIX       (0)
00016 #define LOG_OUTPUT_VERBOSE_PREFIX     (0)
00017 
00018 extern Serial pc;
00019 
00020 #define logOut pc.printf
00021 
00022 #define logError(fmt, args...)\
00023     do {\
00024         if (LOG_OUTPUT_ERROR)\
00025         {\
00026             if(LOG_OUTPUT_ERROR_PREFIX)\
00027                 logOut("[LOG Error:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\
00028             logOut(fmt, ##args);\
00029             logOut("\r\n");\
00030         }\
00031     } while(0)
00032 
00033 #define logWarn(fmt, args...)\
00034     do {\
00035         if (LOG_OUTPUT_WARN)\
00036         {\
00037             if(LOG_OUTPUT_WARN_PREFIX)\
00038                 logOut("[LOG Warn:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\
00039             logOut(fmt, ##args);\
00040             logOut("\r\n");\
00041         }\
00042     } while(0)
00043 
00044 #define logDebug(fmt, args...)\
00045     do {\
00046         if (LOG_OUTPUT_DEBUG)\
00047         {\
00048             if (LOG_OUTPUT_DEBUG_PREFIX)\
00049                 logOut("[LOG Debug:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\
00050             logOut(fmt, ##args);\
00051             logOut("\r\n");\
00052         }\
00053     } while(0)
00054 
00055 #define logInfo(fmt, args...)\
00056     do {\
00057         if (LOG_OUTPUT_INFO)\
00058         {\
00059             if (LOG_OUTPUT_INFO_PREFIX)\
00060                 logOut("[LOG Info:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\
00061             logOut(fmt, ##args);\
00062             logOut("\r\n");\
00063         }\
00064     } while(0)
00065         
00066 
00067 #define logVerbose(fmt, args...)\
00068     do {\
00069         if (LOG_OUTPUT_VERBOSE)\
00070         {\
00071             if (LOG_OUTPUT_VERBOSE_PREFIX)\
00072                 logOut("[LOG Verbose:%s,%d,%s] ",__FILE__,__LINE__,__FUNCTION__);\
00073             logOut(fmt, ##args);\
00074             logOut("\r\n");\
00075         }\
00076     } while(0)
00077 
00078 
00079 #endif /* #ifndef __DEBUG_H__ */