diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 6efe7cf..33f615a 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -14,4 +14,121 @@ config WPS_TYPE_DISABLE bool "disable" endchoice +choice APP_LOG_LEVEL + prompt "APP Log Level" + default APP_LOG_LEVEL_INFO + help + Logging level for APP main + +config APP_LOG_LEVEL_NONE + bool "No output" +config APP_LOG_LEVEL_ERROR + bool "Error" +config APP_LOG_LEVEL_WARN + bool "Warning" +config APP_LOG_LEVEL_INFO + bool "Info" +config APP_LOG_LEVEL_DEBUG + bool "Debug" +config APP_LOG_LEVEL_VERBOSE + bool "Verbose" +endchoice + +config APP_LOG_LEVEL + int + default 0 if APP_LOG_LEVEL_NONE + default 1 if APP_LOG_LEVEL_ERROR + default 2 if APP_LOG_LEVEL_WARN + default 3 if APP_LOG_LEVEL_INFO + default 4 if APP_LOG_LEVEL_DEBUG + default 5 if APP_LOG_LEVEL_VERBOSE + + +choice GPS_LOG_LEVEL + prompt "GPS Log Level" + default GPS_LOG_LEVEL_INFO + help + Logging level for GPS task + +config GPS_LOG_LEVEL_NONE + bool "No output" +config GPS_LOG_LEVEL_ERROR + bool "Error" +config GPS_LOG_LEVEL_WARN + bool "Warning" +config GPS_LOG_LEVEL_INFO + bool "Info" +config GPS_LOG_LEVEL_DEBUG + bool "Debug" +config GPS_LOG_LEVEL_VERBOSE + bool "Verbose" +endchoice + +config GPS_LOG_LEVEL + int + default 0 if GPS_LOG_LEVEL_NONE + default 1 if GPS_LOG_LEVEL_ERROR + default 2 if GPS_LOG_LEVEL_WARN + default 3 if GPS_LOG_LEVEL_INFO + default 4 if GPS_LOG_LEVEL_DEBUG + default 5 if GPS_LOG_LEVEL_VERBOSE + +choice NTP_LOG_LEVEL + prompt "NTP Log Level" + default NTP_LOG_LEVEL_INFO + help + Logging level for NTP task + +config NTP_LOG_LEVEL_NONE + bool "No output" +config NTP_LOG_LEVEL_ERROR + bool "Error" +config NTP_LOG_LEVEL_WARN + bool "Warning" +config NTP_LOG_LEVEL_INFO + bool "Info" +config NTP_LOG_LEVEL_DEBUG + bool "Debug" +config NTP_LOG_LEVEL_VERBOSE + bool "Verbose" +endchoice + +config NTP_LOG_LEVEL + int + default 0 if NTP_LOG_LEVEL_NONE + default 1 if NTP_LOG_LEVEL_ERROR + default 2 if NTP_LOG_LEVEL_WARN + default 3 if NTP_LOG_LEVEL_INFO + default 4 if NTP_LOG_LEVEL_DEBUG + default 5 if NTP_LOG_LEVEL_VERBOSE + +choice DISPLAY_LOG_LEVEL + prompt "DISPLAY Log Level" + default DISPLAY_LOG_LEVEL_INFO + help + Logging level for DISPLAY task + +config DISPLAY_LOG_LEVEL_NONE + bool "No output" +config DISPLAY_LOG_LEVEL_ERROR + bool "Error" +config DISPLAY_LOG_LEVEL_WARN + bool "Warning" +config DISPLAY_LOG_LEVEL_INFO + bool "Info" +config DISPLAY_LOG_LEVEL_DEBUG + bool "Debug" +config DISPLAY_LOG_LEVEL_VERBOSE + bool "Verbose" +endchoice + +config DISPLAY_LOG_LEVEL + int + default 0 if DISPLAY_LOG_LEVEL_NONE + default 1 if DISPLAY_LOG_LEVEL_ERROR + default 2 if DISPLAY_LOG_LEVEL_WARN + default 3 if DISPLAY_LOG_LEVEL_INFO + default 4 if DISPLAY_LOG_LEVEL_DEBUG + default 5 if DISPLAY_LOG_LEVEL_VERBOSE + endmenu diff --git a/main/display_task.c b/main/display_task.c index a821dc1..2d57b43 100644 --- a/main/display_task.c +++ b/main/display_task.c @@ -125,7 +125,7 @@ static void dsp_task() void start_display() { - esp_log_level_set(TAG, ESP_LOG_INFO); + esp_log_level_set(TAG, CONFIG_DISPLAY_LOG_LEVEL); esp_log_level_set("u8g2_hal", ESP_LOG_INFO); xTaskCreatePinnedToCore(dsp_task, "dsp_task", 1024*4, NULL, DSP_TASK_PRI, NULL, 1); diff --git a/main/esp_gps_ntp.h b/main/esp_gps_ntp.h index c0729d8..595541a 100644 --- a/main/esp_gps_ntp.h +++ b/main/esp_gps_ntp.h @@ -7,6 +7,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE // we have separate config choices for all app parts #include "esp_log.h" #ifndef MAIN_ESP_GPS_NTP_H_ diff --git a/main/esp_gps_ntp_main.c b/main/esp_gps_ntp_main.c index ee2de1e..bb677d4 100644 --- a/main/esp_gps_ntp_main.c +++ b/main/esp_gps_ntp_main.c @@ -6,18 +6,16 @@ software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ + +#include "esp_gps_ntp.h" #include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" #include "esp_system.h" #include "esp_wifi.h" -#include "esp_log.h" #include "esp_wps.h" #include "esp_event_loop.h" #include "nvs_flash.h" -#include "esp_gps_ntp.h" /*set wps mode via "make menuconfig"*/ #if CONFIG_WPS_TYPE_PBC @@ -123,19 +121,20 @@ micros_t IRAM_ATTR micros() void app_main() { - printf("ESP32 GPS NTP Server\n"); + esp_log_level_set(TAG, CONFIG_APP_LOG_LEVEL); + ESP_LOGI(TAG, "ESP32 GPS NTP Server"); /* Print chip information */ esp_chip_info_t chip_info; esp_chip_info(&chip_info); - printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ", + ESP_LOGI(TAG, "This is ESP32 chip with %d CPU cores, WiFi%s%s, ", chip_info.cores, (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); - printf("silicon revision %d, ", chip_info.revision); + ESP_LOGI(TAG, "silicon revision %d, ", chip_info.revision); - printf("\n*****\nRUNNING on core %d\n*****\n", xPortGetCoreID()); + ESP_LOGI(TAG, "***** RUNNING on core %d *****", xPortGetCoreID()); fflush(stdout); /* Initialize NVS — it is used to store PHY calibration data */ diff --git a/main/gps_task.c b/main/gps_task.c index 3651520..919eb30 100644 --- a/main/gps_task.c +++ b/main/gps_task.c @@ -473,7 +473,7 @@ static void gps_task() void start_gps() { - esp_log_level_set(TAG, ESP_LOG_INFO); + esp_log_level_set(TAG, CONFIG_GPS_LOG_LEVEL); xTaskCreatePinnedToCore(gps_task, "gps_task", 1024*2, NULL, GPS_TASK_PRI, NULL, 1); diff --git a/main/ntp_task.c b/main/ntp_task.c index 5860bd1..0566570 100644 --- a/main/ntp_task.c +++ b/main/ntp_task.c @@ -249,7 +249,7 @@ static void ntp_task() void start_ntp() { - esp_log_level_set(TAG, ESP_LOG_INFO); + esp_log_level_set(TAG, CONFIG_NTP_LOG_LEVEL); xTaskCreatePinnedToCore(ntp_task, "ntp_task", 1024*2, NULL, NTP_TASK_PRI, NULL, 1); }