10 #include "PlatformDetermination.h"
20 #ifndef IO_LOGGING_DEFAULT_LEVEL
21 #define IO_LOGGING_DEFAULT_LEVEL (SER_WARNING|SER_ERROR|SER_IOA_INFO|SER_TCMENU_INFO|SER_NETWORK_INFO|SER_DEBUG|SER_USER_1)
34 SER_TCMENU_INFO = 0x0008,
35 SER_NETWORK_INFO = 0x0010,
36 SER_IOA_INFO = 0x0020,
43 SER_TCMENU_DEBUG = 0x1000,
44 SER_NETWORK_DEBUG = 0x2000,
45 SER_IOA_DEBUG = 0x4000,
46 SER_LOG_EVERYTHING = 0xffff
49 #ifdef IO_LOGGING_DEBUG
57 #include <FileHandle.h>
66 explicit MBedLogger(FileHandle& serialName) : serial(serialName) {}
68 size_t write(uint8_t ch)
override {
73 size_t write(
const char* sz)
override {
74 auto len = strlen(sz);
75 serial.write(sz, len);
81 unsigned long millis();
83 #define IOLOG_MBED_PORT_IF_NEEDED(tx, rx) BufferedSerial serPort(tx, rx);MBedLogger LoggingPort(serPort);
84 #define IOLOG_START_SERIAL serPort.set_baud(115200);
85 #elif defined(BUILD_FOR_PICO_CMAKE)
88 #include <pico/time.h>
89 #ifdef BUILD_PICO_FORCE_UART
93 size_t write(uint8_t ch)
override {
94 uart_putc_raw(uart0, ch);
98 size_t write(
const char* sz)
override {
99 auto len = strlen(sz);
100 for(
int i=0;i<len;i++) uart_putc_raw(uart0, sz[i]);
104 #define IOLOG_START_SERIAL uart_init(uart_get_instance(0), 115200);gpio_set_function(1, GPIO_FUNC_UART);gpio_set_function(0, GPIO_FUNC_UART);
113 size_t write(
const char* sz)
override {
114 auto len = strlen(sz);
115 for(
int i=0;i<len;i++) putchar_raw(sz[i]);
119 #define IOLOG_START_SERIAL stdio_init_all();
122 unsigned long millis();
124 #define IOLOG_MBED_PORT_IF_NEEDED(tx, rx)
129 #define LoggingPort Serial
131 #define IOLOG_START_SERIAL LoggingPort.begin(115200);
132 #define IOLOG_MBED_PORT_IF_NEEDED(tx, rx)
137 #define logTimeAndLevel(title, lvl) LoggingPort.print(millis());LoggingPort.print('-');LoggingPort.print(prettyLevel(lvl));LoggingPort.print(':');LoggingPort.print(title)
159 #define serlogF(lvl, x) if(serLevelEnabled(lvl)) { logTimeAndLevel(F(x), lvl); LoggingPort.println(); }
160 #define serlogF2(lvl, x1, x2) if(serLevelEnabled(lvl)) { logTimeAndLevel(F(x1), lvl); LoggingPort.print(x2);LoggingPort.println(); }
161 #define serlogF3(lvl, x1, x2, x3) if(serLevelEnabled(lvl)) { logTimeAndLevel(F(x1), lvl); LoggingPort.print(x2); LoggingPort.print(' '); LoggingPort.print(x3);LoggingPort.println(); }
162 #define serlogF4(lvl, x1, x2, x3, x4) if(serLevelEnabled(lvl)) { logTimeAndLevel(F(x1), lvl); LoggingPort.print(x2); LoggingPort.print(' '); LoggingPort.print(x3); LoggingPort.print(' '); LoggingPort.print(x4);LoggingPort.println(); }
163 #define serlogFHex(lvl, x1, x2) if(serLevelEnabled(lvl)) { logTimeAndLevel(F(x1), lvl); LoggingPort.print(x2, HEX);LoggingPort.println(); }
164 #define serlogFHex2(lvl, x1, x2, x3) if(serLevelEnabled(lvl)) { logTimeAndLevel(F(x1), lvl); LoggingPort.print(x2, HEX); LoggingPort.print(','); LoggingPort.print(x3, HEX);LoggingPort.println(); }
165 #define serlog(lvl, x) if(serLevelEnabled(lvl)) { logTimeAndLevel(x, lvl);LoggingPort.println(); }
166 #define serlog2(lvl, x1, x2) if(serLevelEnabled(lvl)) { logTimeAndLevel(x1, lvl); LoggingPort.print(x2);LoggingPort.println(); }
167 #define serlog3(lvl, x1, x2, x3) if(serLevelEnabled(lvl)) { logTimeAndLevel(x1, lvl); LoggingPort.print(x2); LoggingPort.print(' '); LoggingPort.print(x3);LoggingPort.println(); }
168 #define serlogHex(lvl, x1, x2) if(serLevelEnabled(lvl)) { logTimeAndLevel(x1, lvl); LoggingPort.print(x2, HEX);LoggingPort.println(); }
170 void serlogHexDump(
SerLoggingLevel level,
const char *title,
const void* data,
size_t strlen);
171 inline void serdebugHexDump(
const char *title,
const void* data,
size_t len) { serlogHexDump(SER_DEBUG, title, data, len);}
173 #define serdebugF(x) serlogF(SER_DEBUG, x)
174 #define serdebugF2(x1, x2) serlogF2(SER_DEBUG, x1, x2);
175 #define serdebugF3(x1, x2, x3) serlogF3(SER_DEBUG, x1, x2, x3)
176 #define serdebugF4(x1, x2, x3, x4) serlogF4(SER_DEBUG, x1, x2, x3, x4)
177 #define serdebugFHex(x1, x2) serlogFHex(SER_DEBUG, x1, x2)
178 #define serdebugFHex2(x1, x2, x3) serlogFHex2(SER_DEBUG, x1, x2, x3)
179 #define serdebug(x) serlog(SER_DEBUG, x)
180 #define serdebug2(x1, x2) serlog2(SER_DEBUG, x1, x2)
181 #define serdebug3(x1, x2, x3) serlog3(SER_DEBUG, x1, x2, x3)
182 #define serdebugHex(x1, x2) serlogHex(SER_DEBUG, x1, x2)
184 void startTaskManagerLogDelegate();
189 #define serdebugF2(x, y)
190 #define serdebugF3(x, y, z)
191 #define serdebugF4(a, b, c, d)
192 #define serdebugFHex(x, y)
193 #define serdebugFHex2(x, y, z)
195 #define serdebug2(x, y)
196 #define serdebug3(x, y, z)
197 #define serdebugHex(x, y)
198 #define serdebugHexDump(x, str, strlen)
199 #define serlogHexDump(l, x, str, len)
200 #define serlogF(lvl, x)
201 #define serlogF2(lvl, x1, x2)
202 #define serlogF3(lvl, x1, x2, x3)
203 #define serlogF4(lvl, x1, x2, x3, x4)
204 #define serlogFHex(lvl, x1, x2)
205 #define serlogFHex2(lvl, x1, x2, x3)
206 #define serlog(lvl, x)
207 #define serlog2(lvl, x1, x2)
208 #define serlog3(lvl, x1, x2, x3)
209 #define serlogHex(lvl, x1, x2)
211 #define startTaskManagerLogDelegate()
213 #define IOLOG_START_SERIAL
214 #define IOLOG_MBED_PORT_IF_NEEDED(tx, rx)
216 #define serEnableLevel(l, a)
217 #define serLevelEnabled(l) false
unsigned int enabledLevels
Definition: IoLogging.cpp:14
SerLoggingLevel
Definition: IoLogging.h:30
void serEnableLevel(SerLoggingLevel level, bool active)
Definition: IoLogging.h:151
bool serLevelEnabled(SerLoggingLevel level)
Definition: IoLogging.h:144
Compatibility with the Arduino Print API for mbed boards, should never be included in an Arduino buil...
Definition: IoLogging.h:62
size_t write(uint8_t ch) override
Definition: IoLogging.h:68
size_t write(const char *sz) override
Definition: IoLogging.h:73
Definition: PrintCompat.h:31
Definition: IoLogging.h:90
size_t write(uint8_t ch) override
Definition: IoLogging.h:93
size_t write(const char *sz) override
Definition: IoLogging.h:98