Skip to content

Commit 55b8f67

Browse files
authored
In esp32-hal-log, direct calls to ESP_LOG_x macros is more efficient than using intermediate function log_to_esp (espressif#5081)
As indicated in espressif#4845 (comment) it is more efficient to call directly the ESP LOG macros. This spares a function call, a 512b buffer and a call to vsnprintf. No change in functionality.
1 parent 9c20f1b commit 55b8f67

File tree

3 files changed

+5
-26
lines changed

3 files changed

+5
-26
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ set(CORE_SRCS
77
cores/esp32/esp32-hal-dac.c
88
cores/esp32/esp32-hal-gpio.c
99
cores/esp32/esp32-hal-i2c.c
10-
cores/esp32/esp32-hal-log.c
1110
cores/esp32/esp32-hal-ledc.c
1211
cores/esp32/esp32-hal-matrix.c
1312
cores/esp32/esp32-hal-misc.c

cores/esp32/esp32-hal-log.c

Lines changed: 0 additions & 19 deletions
This file was deleted.

cores/esp32/esp32-hal-log.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ int log_printf(const char *fmt, ...);
8888
#define log_v(format, ...) log_printf(ARDUHAL_LOG_FORMAT(V, format), ##__VA_ARGS__)
8989
#define isr_log_v(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(V, format), ##__VA_ARGS__)
9090
#else
91-
#define log_v(format, ...) do {log_to_esp(TAG, ESP_LOG_VERBOSE, format, ##__VA_ARGS__);}while(0)
91+
#define log_v(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_VERBOSE, TAG, format, ##__VA_ARGS__);}while(0)
9292
#define isr_log_v(format, ...) do {ets_printf(LOG_FORMAT(V, format), esp_log_timestamp(), TAG, ##__VA_ARGS__);}while(0)
9393
#endif
9494
#else
@@ -101,7 +101,7 @@ int log_printf(const char *fmt, ...);
101101
#define log_d(format, ...) log_printf(ARDUHAL_LOG_FORMAT(D, format), ##__VA_ARGS__)
102102
#define isr_log_d(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(D, format), ##__VA_ARGS__)
103103
#else
104-
#define log_d(format, ...) do {log_to_esp(TAG, ESP_LOG_DEBUG, format, ##__VA_ARGS__);}while(0)
104+
#define log_d(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_DEBUG, TAG, format, ##__VA_ARGS__);}while(0)
105105
#define isr_log_d(format, ...) do {ets_printf(LOG_FORMAT(D, format), esp_log_timestamp(), TAG, ##__VA_ARGS__);}while(0)
106106
#endif
107107
#else
@@ -114,7 +114,7 @@ int log_printf(const char *fmt, ...);
114114
#define log_i(format, ...) log_printf(ARDUHAL_LOG_FORMAT(I, format), ##__VA_ARGS__)
115115
#define isr_log_i(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(I, format), ##__VA_ARGS__)
116116
#else
117-
#define log_i(format, ...) do {log_to_esp(TAG, ESP_LOG_INFO, format, ##__VA_ARGS__);}while(0)
117+
#define log_i(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, TAG, format, ##__VA_ARGS__);}while(0)
118118
#define isr_log_i(format, ...) do {ets_printf(LOG_FORMAT(I, format), esp_log_timestamp(), TAG, ##__VA_ARGS__);}while(0)
119119
#endif
120120
#else
@@ -127,7 +127,7 @@ int log_printf(const char *fmt, ...);
127127
#define log_w(format, ...) log_printf(ARDUHAL_LOG_FORMAT(W, format), ##__VA_ARGS__)
128128
#define isr_log_w(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(W, format), ##__VA_ARGS__)
129129
#else
130-
#define log_w(format, ...) do {log_to_esp(TAG, ESP_LOG_WARN, format, ##__VA_ARGS__);}while(0)
130+
#define log_w(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_WARN, TAG, format, ##__VA_ARGS__);}while(0)
131131
#define isr_log_w(format, ...) do {ets_printf(LOG_FORMAT(W, format), esp_log_timestamp(), TAG, ##__VA_ARGS__);}while(0)
132132
#endif
133133
#else
@@ -153,7 +153,7 @@ int log_printf(const char *fmt, ...);
153153
#define log_n(format, ...) log_printf(ARDUHAL_LOG_FORMAT(E, format), ##__VA_ARGS__)
154154
#define isr_log_n(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(E, format), ##__VA_ARGS__)
155155
#else
156-
#define log_n(format, ...) do {log_to_esp(TAG, ESP_LOG_ERROR, format, ##__VA_ARGS__);}while(0)
156+
#define log_n(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_ERROR, TAG, format, ##__VA_ARGS__);}while(0)
157157
#define isr_log_n(format, ...) do {ets_printf(LOG_FORMAT(E, format), esp_log_timestamp(), TAG, ##__VA_ARGS__);}while(0)
158158
#endif
159159
#else
@@ -167,7 +167,6 @@ int log_printf(const char *fmt, ...);
167167
#ifndef TAG
168168
#define TAG "ARDUINO"
169169
#endif
170-
void log_to_esp(char* tag, esp_log_level_t level, const char* format, ...);
171170
//#define log_n(format, ...) myLog(ESP_LOG_NONE, format, ##__VA_ARGS__)
172171
#else
173172
#ifdef CONFIG_ARDUHAL_ESP_LOG

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy