nicer logging

This commit is contained in:
2016-03-25 23:08:41 +01:00
parent a55c25ddca
commit 2a4b72fbb5
10 changed files with 92 additions and 25 deletions
+41 -9
View File
@@ -1,19 +1,51 @@
#ifndef HTTPD_LOGGING_H
#define HTTPD_LOGGING_H
#ifndef httpd_printf
#define httpd_printf(fmt, ...) os_printf(fmt, ##__VA_ARGS__)
#endif
#include <esp8266.h>
#include "uptime.h"
// logging functions
#define LOG_EOL "\n"
#define dbg(fmt, ...) httpd_printf(fmt LOG_EOL, ##__VA_ARGS__);
#define banner(fmt, ...) httpd_printf("\x1b[32;1m"fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__);
#define info(fmt, ...) httpd_printf("\x1b[32m"fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__);
#define error(fmt, ...) httpd_printf("\x1b[31;1m"fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__);
#define warn(fmt, ...) httpd_printf("\x1b[33;1m"fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__);
#define dbg(fmt, ...) \
do { \
uptime_print(); \
printf(" [ ] "fmt LOG_EOL, ##__VA_ARGS__); \
} while(0)
#define banner(fmt, ...) \
do { \
printf("\x1b[32;1m"); \
uptime_print(); \
printf(" [i] "fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__); \
} while(0)
#define info(fmt, ...) \
do { \
printf("\x1b[32m"); \
uptime_print(); \
printf(" [i] "fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__); \
} while(0)
#define error(fmt, ...) \
do { \
printf("\x1b[31;1m"); \
uptime_print(); \
printf(" [E] "fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__); \
} while(0)
#define warn(fmt, ...) \
do { \
printf("\x1b[33;1m"); \
uptime_print(); \
printf(" [W] "fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__); \
} while(0)
#endif // HTTPD_LOGGING_H
+1 -1
View File
@@ -25,7 +25,7 @@ typedef RtosConnType* ConnTypePtr;
#define strlen(a) os_strlen(a)
#define memcmp(a, b, c) os_memcmp(a, b, c)
typedef struct espconn* ConnTypePtr;
#define httpd_printf(format, ...) os_printf(format, ##__VA_ARGS__)
//#define httpd_printf(format, ...) os_printf(format, ##__VA_ARGS__)
#endif