]> granicus.if.org Git - esp-idf/commitdiff
wifi: Set default wifi library log level based on sdkconfig
authorAngus Gratton <angus@espressif.com>
Wed, 2 May 2018 05:11:21 +0000 (15:11 +1000)
committerAngus Gratton <gus@projectgus.com>
Wed, 2 May 2018 05:11:21 +0000 (15:11 +1000)
Has to be set at runtime, due to precompiled wifi libraries.

Prompted by discussion on forum: https://esp32.com/viewtopic.php?f=2&t=5570&p=24216#p24216

components/esp32/wifi_init.c

index be0ba781cf9fa620c4b7f7eac916f69fa9e3d029..bd4437a5b49c66922b11227eeee1c9e8023fa839 100644 (file)
@@ -27,6 +27,15 @@ mesh_event_cb_t g_mesh_event_cb = NULL;
 static esp_pm_lock_handle_t s_wifi_modem_sleep_lock;
 #endif
 
+static void __attribute__((constructor)) s_set_default_wifi_log_level()
+{
+    /* WiFi libraries aren't compiled to know CONFIG_LOG_DEFAULT_LEVEL,
+       so set it at runtime startup. Done here not in esp_wifi_init() to allow
+       the user to set the level again before esp_wifi_init() is called.
+    */
+    esp_log_level_set("wifi", CONFIG_LOG_DEFAULT_LEVEL);
+}
+
 esp_err_t esp_wifi_init(const wifi_init_config_t *config)
 {
 #ifdef CONFIG_PM_ENABLE