worked on FileSystem, started to migrate logging class
This commit is contained in:
71
Debug.h
71
Debug.h
@@ -2,8 +2,12 @@
|
||||
#define DEBUG_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
#include "Platforms.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
extern "C" {
|
||||
#include "ets_sys.h"
|
||||
@@ -25,25 +29,64 @@ extern "C" {
|
||||
}
|
||||
*/
|
||||
|
||||
class Log {
|
||||
|
||||
public:
|
||||
|
||||
template<typename... Args> static void addInfo(const char* module, const char* fmt, Args... args) {
|
||||
add('i', module, fmt, args...);
|
||||
}
|
||||
|
||||
template<typename... Args> static void addError(const char* module, const char* fmt, Args... args) {
|
||||
add('e', module, fmt, args...);
|
||||
while(true) {}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
template<typename... Args> static void add(char level, const char* module, const char* fmt, Args... args) {
|
||||
|
||||
char buf[128];
|
||||
char* dst = buf;
|
||||
|
||||
dst = dst + sprintf(dst, "%c[%-10s] ", level, module);
|
||||
dst = dst + sprintf(dst, fmt, args...);
|
||||
dst = dst + sprintf(dst, "\n");
|
||||
|
||||
#ifdef IS_DESKTOP
|
||||
printf(buf);
|
||||
#elif TEENSY
|
||||
Serial.print(buf);
|
||||
#elif ESP8266
|
||||
os_printf(buf);
|
||||
#elif ESP32
|
||||
printf(buf);
|
||||
#else
|
||||
#error "unsupported platform"
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#if (!defined(DEBUG))
|
||||
|
||||
#define debug(str)
|
||||
#define debugMod(module, str)
|
||||
#define debugMod1(module, str, val)
|
||||
#define debugMod2(module, str, v1, v2)
|
||||
#define debugMod3(module, str, v1, v2, v3)
|
||||
#define debugMod4(module, str, v1, v2, v3, v4)
|
||||
#define debugMod5(module, str, v1, v2, v3, v4, v5)
|
||||
#define debugMod6(module, str, v1, v2, v3, v4, v5, v6)
|
||||
#define debugMod7(module, str, v1, v2, v3, v4, v5, v6, v7)
|
||||
#define debugMod8(module, str, v1, v2, v3, v4, v5, v6, v7, v8)
|
||||
#define debugMod9(module, str, v1, v2, v3, v4, v5, v6, v7, v8, v9)
|
||||
#define IF_DEBUG(a)
|
||||
#define debugShow(a, b)
|
||||
// #define debug(str)
|
||||
// #define debugMod(module, str)
|
||||
// #define debugMod1(module, str, val)
|
||||
// #define debugMod2(module, str, v1, v2)
|
||||
// #define debugMod3(module, str, v1, v2, v3)
|
||||
// #define debugMod4(module, str, v1, v2, v3, v4)
|
||||
// #define debugMod5(module, str, v1, v2, v3, v4, v5)
|
||||
// #define debugMod6(module, str, v1, v2, v3, v4, v5, v6)
|
||||
// #define debugMod7(module, str, v1, v2, v3, v4, v5, v6, v7)
|
||||
// #define debugMod8(module, str, v1, v2, v3, v4, v5, v6, v7, v8)
|
||||
// #define debugMod9(module, str, v1, v2, v3, v4, v5, v6, v7, v8, v9)
|
||||
// #define IF_DEBUG(a)
|
||||
// #define debugShow(a, b)
|
||||
|
||||
#warning "not using debug output"
|
||||
// #warning "not using debug output"
|
||||
|
||||
#elif ESP8266
|
||||
|
||||
|
||||
Reference in New Issue
Block a user