diff --git a/arduino/libretuya/core/lt_logger.c b/arduino/libretuya/core/lt_logger.c index f867fd1..f3feac5 100644 --- a/arduino/libretuya/core/lt_logger.c +++ b/arduino/libretuya/core/lt_logger.c @@ -50,6 +50,9 @@ void lt_log(const uint8_t level, const char *caller, const unsigned short line, void lt_log(const uint8_t level, const char *format, ...) { #endif + if (uart_port == 0xFF) + return; + #if LT_LOGGER_TIMESTAMP float seconds = millis() / 1000.0f; #if LT_PRINTF_BROKEN @@ -136,3 +139,7 @@ void lt_log(const uint8_t level, const char *format, ...) { void lt_log_set_port(uint8_t port) { uart_port = port; } + +void lt_log_disable() { + uart_port = 0xFF; +} diff --git a/arduino/libretuya/core/lt_logger.h b/arduino/libretuya/core/lt_logger.h index c178841..84ac288 100644 --- a/arduino/libretuya/core/lt_logger.h +++ b/arduino/libretuya/core/lt_logger.h @@ -20,6 +20,11 @@ void lt_log(const uint8_t level, const char *format, ...); */ void lt_log_set_port(uint8_t port); +/** + * @brief Disable LT logger. Enable it back using lt_log_set_port(LT_UART_DEFAULT_LOGGER). + */ +void lt_log_disable(); + #if LT_LEVEL_TRACE >= LT_LOGLEVEL #define LT_T(...) LT_LOG(LT_LEVEL_TRACE, __FUNCTION__, __LINE__, __VA_ARGS__) #define LT_V(...) LT_LOG(LT_LEVEL_TRACE, __FUNCTION__, __LINE__, __VA_ARGS__)