ESP8266 part of the f105-motor-demo project (see f105-motor-demo_stm32)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.2 KiB

#ifndef HTTPD_LOGGING_H
#define HTTPD_LOGGING_H
9 years ago
#include <esp8266.h>
#include "uptime.h"
#define VERBOSE 1
// logging functions
#define LOG_EOL "\n"
9 years ago
#define banner(fmt, ...) \
do { \
printf(LOG_EOL "\x1b[32;1m"); \
9 years ago
uptime_print(); \
printf(" [i] "fmt"\x1b[0m" LOG_EOL LOG_EOL, ##__VA_ARGS__); \
9 years ago
} while(0)
// same as 'info', except enabled even if verbose is disabled
#define banner_info(fmt, ...) \
9 years ago
do { \
printf("\x1b[32m"); \
uptime_print(); \
printf(" [i] "fmt"\x1b[0m"LOG_EOL, ##__VA_ARGS__); \
} while(0)
#if VERBOSE
#define dbg(fmt, ...) \
do { \
uptime_print(); \
printf(" [ ] "fmt 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)
#else
#define dbg(fmt, ...)
#define info(fmt, ...)
#endif
9 years ago
#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