diff --git a/arduino/libretuya/core/LibreTuyaConfig.h b/arduino/libretuya/core/LibreTuyaConfig.h index 93cd596..16be532 100644 --- a/arduino/libretuya/core/LibreTuyaConfig.h +++ b/arduino/libretuya/core/LibreTuyaConfig.h @@ -12,6 +12,7 @@ #define LT_LEVEL_WARN 3 #define LT_LEVEL_ERROR 4 #define LT_LEVEL_FATAL 5 +#define LT_LEVEL_NONE 6 // Logger enabled/disabled #ifndef LT_LOGGER @@ -24,11 +25,11 @@ #endif #ifndef LT_LOGGER_CALLER -#define LT_LOGGER_CALLER 1 +#define LT_LOGGER_CALLER 0 #endif #ifndef LT_LOGGER_TASK -#define LT_LOGGER_TASK 1 +#define LT_LOGGER_TASK 0 #endif #ifndef LT_LOGGER_COLOR @@ -44,6 +45,11 @@ #define LT_LOGLEVEL LT_LEVEL_INFO #endif +#if !LT_LOGGER +#undef LT_LOGLEVEL +#define LT_LOGLEVEL LT_LEVEL_NONE +#endif + // Free heap size debugging #ifndef LT_LOG_HEAP #define LT_LOG_HEAP 0 @@ -71,25 +77,29 @@ #define LT_UART_DEFAULT_SERIAL LT_UART_DEFAULT_PORT #endif -// Per-module debugging +// Per-module logging output - applies to all loglevels +#ifndef LT_DEBUG_ALL +#define LT_DEBUG_ALL 0 +#endif + #ifndef LT_DEBUG_WIFI -#define LT_DEBUG_WIFI 0 +#define LT_DEBUG_WIFI 1 #endif #ifndef LT_DEBUG_CLIENT -#define LT_DEBUG_CLIENT 0 +#define LT_DEBUG_CLIENT LT_DEBUG_ALL #endif #ifndef LT_DEBUG_SERVER -#define LT_DEBUG_SERVER 0 +#define LT_DEBUG_SERVER LT_DEBUG_ALL #endif #ifndef LT_DEBUG_SSL -#define LT_DEBUG_SSL 0 +#define LT_DEBUG_SSL LT_DEBUG_ALL #endif #ifndef LT_DEBUG_OTA -#define LT_DEBUG_OTA 0 +#define LT_DEBUG_OTA 1 #endif #ifndef LT_DEBUG_FDB @@ -97,7 +107,7 @@ #endif #ifndef LT_DEBUG_MDNS -#define LT_DEBUG_MDNS 0 +#define LT_DEBUG_MDNS LT_DEBUG_ALL #endif #ifndef LT_DEBUG_LWIP diff --git a/docs/reference/config.md b/docs/reference/config.md index 88ae957..42441b4 100644 --- a/docs/reference/config.md +++ b/docs/reference/config.md @@ -29,34 +29,51 @@ build_flags = ### Logger -- `LT_LOGGER` (1) - enable/disable LibreTuya logger globally. Enabled by default. +- `LT_LOGGER` (1) - enable/disable LibreTuya logger globally; disabling this sets the loglevel to `LT_LEVEL_NONE` - the logger can't be enabled even by using `lt_log_set_port()` - `LT_LOGLEVEL` - global LT loglevel: - - `LT_LEVEL_TRACE` (same as LT_LEVEL_VERBOSE) + - `LT_LEVEL_VERBOSE` + - `LT_LEVEL_TRACE` - same as `LT_LEVEL_VERBOSE` - `LT_LEVEL_DEBUG` - `LT_LEVEL_INFO` - default - `LT_LEVEL_WARN` - `LT_LEVEL_ERROR` - `LT_LEVEL_FATAL` + - `LT_LEVEL_NONE` - disables everything - `LT_LOGGER_TIMESTAMP` (1) - print program runtime in printk-like format - `LT_LOGGER_CALLER` (1) - print calling method name - `LT_LOGGER_TASK` (1) - print calling FreeRTOS task (if available) - `LT_LOGGER_COLOR` (0) - output ANSI terminal colors - `LT_PRINTF_BROKEN` (0) - whether printf outputs "0." for floats with value 0 -- `LT_LOG_HEAP` (0) - print free heap size using `LT_HEAP_I()` +- `LT_LOG_HEAP` (0) - print free heap size using `LT_HEAP_I()`, and periodically every 1000 ms - `LT_LOG_ERRNO` (0) - print and clear errno value (if set) using `LT_ERRNO()` -#### Debug logging +#### Per-module logging & debugging -The following options enable library-specific debugging messages. They are only effective if `LT_LOGLEVEL` is set below INFO. All of them are disabled by default. +The following options enable library-specific logging output. They are effective **for all loglevels** - i.e. disabling `LT_DEBUG_WIFI` will disable WiFi debug messages, as well as errors. -Families should generally call i.e. WiFiClient debugging for client-related code, even if the `WiFiClient.cpp` file is physically absent. +To see debug messages from i.e. OTA, loglevel must also be changed. -- `LT_DEBUG_WIFI` - WiFi -- `LT_DEBUG_WIFI_CLIENT` - WiFiClient -- `LT_DEBUG_WIFI_SERVER` - WiFiServer -- `LT_DEBUG_WIFI_STA` - WiFiSTA -- `LT_DEBUG_WIFI_AP` - WiFiAP -- `LT_DEBUG_SSL` - WiFiClientSecure +- `LT_DEBUG_ALL` (0) - enable all following options by default (except for FDB and LWIP) +- `LT_DEBUG_WIFI` (1) - WiFi (generic, STA, AP, scan, events, etc.) +- `LT_DEBUG_CLIENT` (0) - TCP client +- `LT_DEBUG_SERVER` (0) - TCP server +- `LT_DEBUG_SSL` (0) - SSL clients +- `LT_DEBUG_OTA` (1) - OTA updates (`Update` library) +- `LT_DEBUG_FDB` (0) - FlashDB debugging (macros within the library) +- `LT_DEBUG_MDNS` (0) - mDNS client library +- `LT_DEBUG_LWIP` (0) - enables `LWIP_DEBUG`, provides `LWIP_PLATFORM_DIAG`; per-module options (i.e. `TCP_DEBUG`) are off by default and need to be enabled separately +- `LT_DEBUG_LWIP_ASSERT` (0) - enables assertions within lwIP (doesn't need `LT_DEBUG_LWIP`) + +!!! hint + Enabling `LT_DEBUG_ALL` doesn't mean that *every* debugging message will be printed. If loglevel is i.e. `WARN`, debug messages won't be visible anyway. + + This can be used, for example, to enable only "important" messages: + ```ini + [env:my_board] + build_flags = + -D LT_LOGLEVEL=LT_LEVEL_WARN + -D LT_DEBUG_ALL=1 # will print only warnings and errors from all modules + ``` ### Serial output