diff --git a/components/app_update/esp_ota_ops.c b/components/app_update/esp_ota_ops.c index ceb6a7052..8e26ba162 100644 --- a/components/app_update/esp_ota_ops.c +++ b/components/app_update/esp_ota_ops.c @@ -191,7 +191,7 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size) } //if go to here ,means don't find the handle - ESP_LOGE(TAG,"not found the handle") + ESP_LOGE(TAG,"not found the handle"); return ESP_ERR_INVALID_ARG; } diff --git a/components/esp32/clk.c b/components/esp32/clk.c index 0aa931acd..ec8d73c9b 100644 --- a/components/esp32/clk.c +++ b/components/esp32/clk.c @@ -140,7 +140,7 @@ static void select_rtc_slow_clk(rtc_slow_freq_t slow_clk) uint32_t wait = 0; // increment of 'wait' counter equivalent to 3 seconds const uint32_t warning_timeout = 3 /* sec */ * 32768 /* Hz */ / (2 * XTAL_32K_DETECT_CYCLES); - ESP_EARLY_LOGD(TAG, "waiting for 32k oscillator to start up") + ESP_EARLY_LOGD(TAG, "waiting for 32k oscillator to start up"); do { ++wait; rtc_clk_32k_enable(true); diff --git a/components/log/include/esp_log.h b/components/log/include/esp_log.h index c13a3f227..1c796cfff 100644 --- a/components/log/include/esp_log.h +++ b/components/log/include/esp_log.h @@ -244,26 +244,31 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, . #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%d) %s: " format LOG_RESET_COLOR "\n" /// macro to output logs in startup code, before heap allocator and syscalls have been initialized. log at ``ESP_LOG_ERROR`` level. @see ``printf``,``ESP_LOGE`` -#define ESP_EARLY_LOGE( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR) { ets_printf(LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define ESP_EARLY_LOGE( tag, format, ... ) ESP_LOG_EARLY_IMPL(tag, format, ESP_LOG_ERROR, E, ##__VA_ARGS__) /// macro to output logs in startup code at ``ESP_LOG_WARN`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf`` -#define ESP_EARLY_LOGW( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_WARN) { ets_printf(LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define ESP_EARLY_LOGW( tag, format, ... ) ESP_LOG_EARLY_IMPL(tag, format, ESP_LOG_WARN, W, ##__VA_ARGS__) /// macro to output logs in startup code at ``ESP_LOG_INFO`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf`` -#define ESP_EARLY_LOGI( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { ets_printf(LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define ESP_EARLY_LOGI( tag, format, ... ) ESP_LOG_EARLY_IMPL(tag, format, ESP_LOG_INFO, I, ##__VA_ARGS__) /// macro to output logs in startup code at ``ESP_LOG_DEBUG`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf`` -#define ESP_EARLY_LOGD( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) { ets_printf(LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define ESP_EARLY_LOGD( tag, format, ... ) ESP_LOG_EARLY_IMPL(tag, format, ESP_LOG_DEBUG, D, ##__VA_ARGS__) /// macro to output logs in startup code at ``ESP_LOG_VERBOSE`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf`` -#define ESP_EARLY_LOGV( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE) { ets_printf(LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define ESP_EARLY_LOGV( tag, format, ... ) ESP_LOG_EARLY_IMPL(tag, format, ESP_LOG_VERBOSE, V, ##__VA_ARGS__) + +#define ESP_LOG_EARLY_IMPL(tag, format, log_level, log_tag_letter, ...) do { \ + if (LOG_LOCAL_LEVEL >= log_level) { \ + ets_printf(LOG_FORMAT(log_tag_letter, format), esp_log_timestamp(), tag, ##__VA_ARGS__); \ + }} while(0) #ifndef BOOTLOADER_BUILD -#define ESP_LOGE( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } -#define ESP_LOGW( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_WARN) { esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } -#define ESP_LOGI( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } -#define ESP_LOGD( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) { esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } -#define ESP_LOGV( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE) { esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define ESP_LOGE( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_ERROR, tag, format, ##__VA_ARGS__) +#define ESP_LOGW( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_WARN, tag, format, ##__VA_ARGS__) +#define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) +#define ESP_LOGD( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_DEBUG, tag, format, ##__VA_ARGS__) +#define ESP_LOGV( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_VERBOSE, tag, format, ##__VA_ARGS__) #else /** * macro to output logs at ESP_LOG_ERROR level. - * + * * @param tag tag of the log, which can be used to change the log level by ``esp_log_level_set`` at runtime. * * @see ``printf`` @@ -291,19 +296,21 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, . * * @see ``printf`` */ -#define ESP_LOG_LEVEL(level, tag, format, ...) do {\ - if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }\ - else if (level==ESP_LOG_WARN ) { esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }\ - else if (level==ESP_LOG_DEBUG ) { esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }\ - else if (level==ESP_LOG_VERBOSE ) { esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }\ - else { esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }}while(0) +#define ESP_LOG_LEVEL(level, tag, format, ...) do { \ + if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ + else if (level==ESP_LOG_WARN ) { esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ + else if (level==ESP_LOG_DEBUG ) { esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ + else if (level==ESP_LOG_VERBOSE ) { esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ + else { esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ + } while(0) /** runtime macro to output logs at a specified level. Also check the level with ``LOG_LOCAL_LEVEL``. - * + * * @see ``printf``, ``ESP_LOG_LEVEL`` */ -#define ESP_LOG_LEVEL_LOCAL(level, tag, format, ...) do {\ - if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); } while(0); +#define ESP_LOG_LEVEL_LOCAL(level, tag, format, ...) do { \ + if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/examples/mesh/internal_transceiver/main/mesh_main.c b/examples/mesh/internal_transceiver/main/mesh_main.c index ceffbdd3c..6e6bebf12 100644 --- a/examples/mesh/internal_transceiver/main/mesh_main.c +++ b/examples/mesh/internal_transceiver/main/mesh_main.c @@ -72,13 +72,13 @@ void mesh_send_to_group(const mesh_data_t *data, const mesh_addr_t *group, int s "[GROUP:%d][L:%d][rtableSize:%d]parent:"MACSTR" to "MACSTR", heap:%d[err:0x%x, proto:%d, tos:%d]", seqno, mesh_layer, esp_mesh_get_routing_table_size(), MAC2STR(mesh_parent_addr.addr), MAC2STR(group->addr), - esp_get_free_heap_size(), err, data->proto, data->tos) + esp_get_free_heap_size(), err, data->proto, data->tos); } else { ESP_LOGW(MESH_TAG, "[GROUP:%d][L:%d][rtableSize:%d]parent:"MACSTR" to "MACSTR", heap:%d[err:0x%x, proto:%d, tos:%d]", seqno, mesh_layer, esp_mesh_get_routing_table_size(), MAC2STR(mesh_parent_addr.addr), MAC2STR(group->addr), - esp_get_free_heap_size(), err, data->proto, data->tos) + esp_get_free_heap_size(), err, data->proto, data->tos); } } @@ -104,7 +104,7 @@ void esp_mesh_p2p_tx_main(void *arg) ESP_LOGI(MESH_TAG, "layer:%d, rtableSize:%d, %s%s", mesh_layer, esp_mesh_get_routing_table_size(), is_mesh_connected ? "CONNECT" : "DISCONNECT", - esp_mesh_is_root() ? "" : "[NODE]") + esp_mesh_is_root() ? "" : "[NODE]"); vTaskDelay(10 * 1000 / portTICK_RATE_MS); continue; } @@ -113,7 +113,7 @@ void esp_mesh_p2p_tx_main(void *arg) CONFIG_MESH_ROUTE_TABLE_SIZE * 6, &route_table_size); if (send_count && !(send_count % 100)) { ESP_LOGI(MESH_TAG, "size:%d/%d,send_count:%d", route_table_size, - esp_mesh_get_routing_table_size(), send_count) + esp_mesh_get_routing_table_size(), send_count); } send_count++; tx_buf[25] = (send_count >> 24) & 0xff; @@ -138,7 +138,7 @@ void esp_mesh_p2p_tx_main(void *arg) "[ROOT-2-UNICAST:%d][L:%d]parent:"MACSTR" to "MACSTR", heap:%d[err:0x%x, proto:%d, tos:%d]", send_count, mesh_layer, MAC2STR(mesh_parent_addr.addr), MAC2STR(route_table[i].addr), esp_get_free_heap_size(), - err, data.proto, data.tos) + err, data.proto, data.tos); } else if (!(send_count % 100)) { ESP_LOGW(MESH_TAG, "[ROOT-2-UNICAST:%d][L:%d][rtableSize:%d]parent:"MACSTR" to "MACSTR", heap:%d[err:0x%x, proto:%d, tos:%d]", @@ -146,7 +146,7 @@ void esp_mesh_p2p_tx_main(void *arg) esp_mesh_get_routing_table_size(), MAC2STR(mesh_parent_addr.addr), MAC2STR(route_table[i].addr), esp_get_free_heap_size(), - err, data.proto, data.tos) + err, data.proto, data.tos); } } if (route_table_size < 10) { @@ -172,7 +172,7 @@ void esp_mesh_p2p_rx_main(void *arg) data.size = RX_SIZE; err = esp_mesh_recv(&from, &data, portMAX_DELAY, &flag, NULL, 0); if (err != ESP_OK || !data.size) { - ESP_LOGE(MESH_TAG, "err:0x%x, size:%d", err, data.size) + ESP_LOGE(MESH_TAG, "err:0x%x, size:%d", err, data.size); continue; } /* extract send count */ @@ -189,7 +189,7 @@ void esp_mesh_p2p_rx_main(void *arg) recv_count, send_count, mesh_layer, MAC2STR(mesh_parent_addr.addr), MAC2STR(from.addr), data.size, esp_get_free_heap_size(), flag, err, data.proto, - data.tos) + data.tos); } } vTaskDelete(NULL); @@ -213,40 +213,40 @@ void esp_mesh_event_handler(mesh_event_t event) #endif static uint8_t last_layer = 0; static int disconnect_count = 0; - ESP_LOGD(MESH_TAG, "esp_event_handler:%d", event.id) + ESP_LOGD(MESH_TAG, "esp_event_handler:%d", event.id); switch (event.id) { case MESH_EVENT_STARTED: - ESP_LOGI(MESH_TAG, "") + ESP_LOGI(MESH_TAG, ""); break; case MESH_EVENT_STOPPED: - ESP_LOGI(MESH_TAG, "") + ESP_LOGI(MESH_TAG, ""); break; case MESH_EVENT_CHILD_CONNECTED: ESP_LOGI(MESH_TAG, "aid:%d, "MACSTR"", event.info.child_connected.aid, - MAC2STR(event.info.child_connected.mac)) + MAC2STR(event.info.child_connected.mac)); break; case MESH_EVENT_CHILD_DISCONNECTED: ESP_LOGI(MESH_TAG, "aid:%d, "MACSTR"", event.info.child_disconnected.aid, - MAC2STR(event.info.child_disconnected.mac)) + MAC2STR(event.info.child_disconnected.mac)); break; case MESH_EVENT_ROUTING_TABLE_ADD: ESP_LOGW(MESH_TAG, "add %d, new:%d", event.info.routing_table.rt_size_change, - event.info.routing_table.rt_size_new) + event.info.routing_table.rt_size_new); break; case MESH_EVENT_ROUTING_TABLE_REMOVE: ESP_LOGW(MESH_TAG, "remove %d, new:%d", event.info.routing_table.rt_size_change, - event.info.routing_table.rt_size_new) + event.info.routing_table.rt_size_new); break; case MESH_EVENT_NO_PARNET_FOUND: ESP_LOGI(MESH_TAG, "scan times:%d", - event.info.no_parent.scan_times) + event.info.no_parent.scan_times); /* TODO handler for the failure */ break; @@ -257,7 +257,7 @@ void esp_mesh_event_handler(mesh_event_t event) "layer:%d-->%d, parent:"MACSTR"%s, discnx:%d", last_layer, mesh_layer, MAC2STR(mesh_parent_addr.addr), esp_mesh_is_root() ? "" : - (mesh_layer == 2) ? "" : "", disconnect_count) + (mesh_layer == 2) ? "" : "", disconnect_count); disconnect_count = 0; last_layer = mesh_layer; mesh_connected_indicator(mesh_layer); @@ -271,7 +271,7 @@ void esp_mesh_event_handler(mesh_event_t event) esp_mesh_set_group_id((mesh_addr_t * ) MESH_GROUP_ID, 1)) ESP_ERROR_CHECK(esp_mesh_get_group_list(&group, 1)) ESP_LOGI(MESH_TAG, "num:%d, group "MACSTR"\n", - esp_mesh_get_group_num(), MAC2STR(group.addr)) + esp_mesh_get_group_num(), MAC2STR(group.addr)); } #endif esp_mesh_comm_p2p_start(); @@ -280,7 +280,7 @@ void esp_mesh_event_handler(mesh_event_t event) case MESH_EVENT_PARENT_DISCONNECTED: ESP_LOGI(MESH_TAG, "reason:%d, count:%d", - event.info.disconnected.reason, disconnect_count) + event.info.disconnected.reason, disconnect_count); if (event.info.disconnected.reason == 201) { disconnect_count++; } @@ -293,14 +293,14 @@ void esp_mesh_event_handler(mesh_event_t event) ESP_LOGI(MESH_TAG, "layer:%d-->%d%s", last_layer, mesh_layer, esp_mesh_is_root() ? "" : - (mesh_layer == 2) ? "" : "") + (mesh_layer == 2) ? "" : ""); last_layer = mesh_layer; mesh_connected_indicator(mesh_layer); break; case MESH_EVENT_ROOT_ADDRESS: ESP_LOGI(MESH_TAG, "rc_addr:"MACSTR"", - MAC2STR(event.info.root_addr.addr)) + MAC2STR(event.info.root_addr.addr)); break; case MESH_EVENT_ROOT_GOT_IP: @@ -309,11 +309,11 @@ void esp_mesh_event_handler(mesh_event_t event) "sta ip: " IPSTR ", mask: " IPSTR ", gw: " IPSTR, IP2STR(&event.info.got_ip.ip_info.ip), IP2STR(&event.info.got_ip.ip_info.netmask), - IP2STR(&event.info.got_ip.ip_info.gw)) + IP2STR(&event.info.got_ip.ip_info.gw)); break; case MESH_EVENT_ROOT_LOST_IP: - ESP_LOGI(MESH_TAG, "") + ESP_LOGI(MESH_TAG, ""); break; case MESH_EVENT_VOTE_STARTED: @@ -321,29 +321,29 @@ void esp_mesh_event_handler(mesh_event_t event) "attempts:%d, reason:%d, rc_addr:"MACSTR"", event.info.vote_started.attempts, event.info.vote_started.reason, - MAC2STR(event.info.vote_started.rc_addr.addr)) + MAC2STR(event.info.vote_started.rc_addr.addr)); break; case MESH_EVENT_VOTE_STOPPED: - ESP_LOGI(MESH_TAG, "") + ESP_LOGI(MESH_TAG, ""); break; case MESH_EVENT_ROOT_SWITCH_REQ: ESP_LOGI(MESH_TAG, "reason:%d, rc_addr:"MACSTR"", event.info.switch_req.reason, - MAC2STR( event.info.switch_req.rc_addr.addr)) + MAC2STR( event.info.switch_req.rc_addr.addr)); break; case MESH_EVENT_ROOT_SWITCH_ACK: - ESP_LOGI(MESH_TAG, "") + ESP_LOGI(MESH_TAG, ""); break; case MESH_EVENT_TODS_STATE: ESP_LOGI(MESH_TAG, "state:%d", - event.info.toDS_state) + event.info.toDS_state); ; break; default: - ESP_LOGI(MESH_TAG, "unknown") + ESP_LOGI(MESH_TAG, "unknown"); break; } } @@ -403,5 +403,5 @@ void app_main(void) ESP_ERROR_CHECK(esp_mesh_set_switch_parent_paras(&switch_paras)); /* mesh start */ ESP_ERROR_CHECK(esp_mesh_start()); - ESP_LOGI(MESH_TAG, "mesh starts successfully, heap:%d\n", esp_get_free_heap_size()) + ESP_LOGI(MESH_TAG, "mesh starts successfully, heap:%d\n", esp_get_free_heap_size()); } diff --git a/examples/protocols/openssl_server/main/openssl_server_example_main.c b/examples/protocols/openssl_server/main/openssl_server_example_main.c index d6021e8b2..c3e007563 100755 --- a/examples/protocols/openssl_server/main/openssl_server_example_main.c +++ b/examples/protocols/openssl_server/main/openssl_server_example_main.c @@ -163,13 +163,13 @@ reconnect: ESP_LOGI(TAG, "SSL read: %s", recv_buf); if (strstr(recv_buf, "GET ") && strstr(recv_buf, " HTTP/1.1")) { - ESP_LOGI(TAG, "SSL get matched message") - ESP_LOGI(TAG, "SSL write message") + ESP_LOGI(TAG, "SSL get matched message"); + ESP_LOGI(TAG, "SSL write message"); ret = SSL_write(ssl, send_data, send_bytes); if (ret > 0) { - ESP_LOGI(TAG, "OK") + ESP_LOGI(TAG, "OK"); } else { - ESP_LOGI(TAG, "error") + ESP_LOGI(TAG, "error"); } break; }