EnigmaIOT  0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
EnigmaIOTdebug.h
Go to the documentation of this file.
1 
15 #ifndef _DEBUG_h
16 #define _DEBUG_h
17 
18 #include <Arduino.h>
19 #include "EnigmaIoTconfig.h"
20 #ifdef ESP32
21 #include <esp_log.h>
22 #endif
23 
24 #define NO_DEBUG 0
25 #define ERROR 1
26 #define WARN 2
27 #define INFO 3
28 #define DBG 4
29 #define VERBOSE 5
30 
31 #ifdef ESP8266
32 const char* extractFileName (const char* path);
33 #define DEBUG_LINE_PREFIX() DEBUG_ESP_PORT.printf_P (PSTR("[%lu][H:%5lu][%s:%d] %s() | "),millis(),(unsigned long)ESP.getFreeHeap(),extractFileName(__FILE__),__LINE__,__FUNCTION__)
34 #endif
35 
36 #ifdef DEBUG_ESP_PORT
37 
38 #ifdef ESP8266
39 #if DEBUG_LEVEL >= VERBOSE
40 #define DEBUG_VERBOSE(text,...) DEBUG_ESP_PORT.print("V ");DEBUG_LINE_PREFIX();DEBUG_ESP_PORT.printf_P(PSTR(text),##__VA_ARGS__);DEBUG_ESP_PORT.println()
41 #else
42 #define DEBUG_VERBOSE(...)
43 #endif
44 
45 #if DEBUG_LEVEL >= DBG
46 #define DEBUG_DBG(text,...) DEBUG_ESP_PORT.print("D ");DEBUG_LINE_PREFIX(); DEBUG_ESP_PORT.printf_P(PSTR(text),##__VA_ARGS__);DEBUG_ESP_PORT.println()
47 #else
48 #define DEBUG_DBG(...)
49 #endif
50 
51 #if DEBUG_LEVEL >= INFO
52 #define DEBUG_INFO(text,...) DEBUG_ESP_PORT.print("I ");DEBUG_LINE_PREFIX();DEBUG_ESP_PORT.printf_P(PSTR(text),##__VA_ARGS__);DEBUG_ESP_PORT.println()
53 #else
54 #define DEBUG_INFO(...)
55 #endif
56 
57 #if DEBUG_LEVEL >= WARN
58 #define DEBUG_WARN(text,...) DEBUG_ESP_PORT.print("W ");DEBUG_LINE_PREFIX();DEBUG_ESP_PORT.printf_P(PSTR(text),##__VA_ARGS__);DEBUG_ESP_PORT.println()
59 #else
60 #define DEBUG_WARN(...)
61 #endif
62 
63 #if DEBUG_LEVEL >= ERROR
64 #define DEBUG_ERROR(text,...) DEBUG_ESP_PORT.print("E ");DEBUG_LINE_PREFIX();DEBUG_ESP_PORT.printf_P(PSTR(text),##__VA_ARGS__);DEBUG_ESP_PORT.println()
65 #else
66 #define DEBUG_ERROR(...)
67 #endif
68 #elif defined ESP32
69 #define DEFAULT_LOG_TAG "EnigmaIOT"
70 #define DEBUG_VERBOSE(format,...) ESP_LOGV (DEFAULT_LOG_TAG,"%d Heap: %6d. " format, millis(), ESP.getFreeHeap(), ##__VA_ARGS__)
71 #define DEBUG_DBG(format,...) ESP_LOGD (DEFAULT_LOG_TAG,"%d Heap: %6d " format, millis(), ESP.getFreeHeap(), ##__VA_ARGS__)
72 #define DEBUG_INFO(format,...) ESP_LOGI (DEFAULT_LOG_TAG,"%d Heap: %6d " format, millis(), ESP.getFreeHeap(), ##__VA_ARGS__)
73 #define DEBUG_WARN(format,...) ESP_LOGW (DEFAULT_LOG_TAG,"%d Heap: %6d " format, millis(), ESP.getFreeHeap(), ##__VA_ARGS__)
74 #define DEBUG_ERROR(format,...) ESP_LOGE (DEFAULT_LOG_TAG,"%d Heap: %6d " format, millis(), ESP.getFreeHeap(), ##__VA_ARGS__)
75 #endif
76 #else
77 #define DEBUG_VERBOSE(...)
78 #define DEBUG_DBG(...)
79 #define DEBUG_INFO(...)
80 #define DEBUG_WARN(...)
81 #define DEBUG_ERROR(...)
82 #endif
83 
84 
85 
86 #endif
87 
EnigmaIoTconfig.h
Parameter configuration.