SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
local_debug.h
Go to the documentation of this file.
1#ifndef _local_debug_H_
2#define _local_debug_H_
3
4#include "Arduino.h"
5#include "Print.h"
6
7namespace sensesp {
8
9#ifndef DEBUG_DISABLED
10
11#define rdebugA(fmt, ...) \
12 if (Debug.isActive(Debug.ANY)) \
13 Serial.printf("(%s)(C%d) " fmt, __func__, xPortGetCoreID(), ##__VA_ARGS__)
14#define rdebugP(fmt, ...) \
15 if (Debug.isActive(Debug.PROFILER)) \
16 Serial.printf("(%s)(C%d) " fmt, __func__, xPortGetCoreID(), ##__VA_ARGS__)
17#define rdebugV(fmt, ...) \
18 if (Debug.isActive(Debug.VERBOSE)) \
19 Serial.printf("(%s)(C%d) " fmt, __func__, xPortGetCoreID(), ##__VA_ARGS__)
20#define rdebugD(fmt, ...) \
21 if (Debug.isActive(Debug.DEBUG)) \
22 Serial.printf("(%s)(C%d) " fmt, __func__, xPortGetCoreID(), ##__VA_ARGS__)
23#define rdebugI(fmt, ...) \
24 if (Debug.isActive(Debug.INFO)) \
25 Serial.printf("(%s)(C%d) " fmt, __func__, xPortGetCoreID(), ##__VA_ARGS__)
26#define rdebugW(fmt, ...) \
27 if (Debug.isActive(Debug.WARNING)) \
28 Serial.printf("(%s)(C%d) " fmt, __func__, xPortGetCoreID(), ##__VA_ARGS__)
29#define rdebugE(fmt, ...) \
30 if (Debug.isActive(Debug.ERROR)) \
31 Serial.printf("(%s)(C%d) " fmt, __func__, xPortGetCoreID(), ##__VA_ARGS__)
32
33// With newline
34
35#define rdebugAln(fmt, ...) rdebugA(fmt "\n", ##__VA_ARGS__)
36#define rdebugPln(fmt, ...) rdebugP(fmt "\n", ##__VA_ARGS__)
37#define rdebugVln(fmt, ...) rdebugV(fmt "\n", ##__VA_ARGS__)
38#define rdebugDln(fmt, ...) rdebugD(fmt "\n", ##__VA_ARGS__)
39#define rdebugIln(fmt, ...) rdebugI(fmt "\n", ##__VA_ARGS__)
40#define rdebugWln(fmt, ...) rdebugW(fmt "\n", ##__VA_ARGS__)
41#define rdebugEln(fmt, ...) rdebugE(fmt "\n", ##__VA_ARGS__)
42
43// New way: To compatibility with SerialDebug (can use RemoteDebug or
44// SerialDebug) This is my favorite :)
45
46#define debugV(fmt, ...) rdebugVln(fmt, ##__VA_ARGS__)
47#define debugD(fmt, ...) rdebugDln(fmt, ##__VA_ARGS__)
48#define debugI(fmt, ...) rdebugIln(fmt, ##__VA_ARGS__)
49#define debugW(fmt, ...) rdebugWln(fmt, ##__VA_ARGS__)
50#define debugE(fmt, ...) rdebugEln(fmt, ##__VA_ARGS__)
51#define debugA(fmt, ...) rdebugVln(fmt, ##__VA_ARGS__)
52
54 public:
56
57 void setSerialEnabled(bool enable) {} // No-op
58
59 void setResetCmdEnabled(bool enable) {} // No-op
60
62
63 // Debug levels
64
65 static const uint8_t PROFILER =
66 0; // Used for show time of execution of pieces of code(profiler)
67 static const uint8_t VERBOSE = 1; // Used for show verboses messages
68 static const uint8_t DEBUG = 2; // Used for show debug messages
69 static const uint8_t INFO = 3; // Used for show info messages
70 static const uint8_t WARNING = 4; // Used for show warning messages
71 static const uint8_t ERROR = 5; // Used for show error messages
72 static const uint8_t ANY =
73 6; // Used for show always messages, for any current debug level
74
75 private:
76 uint8_t lastDebugLevel_ = DEBUG;
77};
78
79#else // DEBUG_DISABLED
80
81#define debugA(...)
82#define debugP(...)
83#define debugV(...)
84#define debugD(...)
85#define debugI(...)
86#define debugW(...)
87#define debugE(...)
88
89#endif
90
91} // namespace sensesp
92
93#endif
Construct a new transform based on a single function.
void setSerialEnabled(bool enable)
Definition local_debug.h:57
static const uint8_t PROFILER
Definition local_debug.h:65
boolean isActive(uint8_t debugLevel=DEBUG)
static const uint8_t ANY
Definition local_debug.h:72
static const uint8_t VERBOSE
Definition local_debug.h:67
void setResetCmdEnabled(bool enable)
Definition local_debug.h:59
static const uint8_t DEBUG
Definition local_debug.h:68
bool begin(String hostname, uint8_t startingDebugLevel=DEBUG)
static const uint8_t INFO
Definition local_debug.h:69
static const uint8_t WARNING
Definition local_debug.h:70
static const uint8_t ERROR
Definition local_debug.h:71