You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -68,7 +68,7 @@ Log level settings control which logs are included in the binary and their visib
68
68
69
69
Example for the application: if the **log level** is set to **Warning** and the **maximum log level** is set to **Debug**, the binary will include log messages of levels **Error**, **Warning**, **Info**, and **Debug**. However, at runtime, only log messages of levels **Error** and **Warning** will be outputted unless the log level is explicitly changed using :cpp:func:`esp_log_level_set`. The log level can be adjusted, increased or decreased, depending on the user's needs.
70
70
71
-
**Maximum Log Level** Setting
71
+
``Maximum Log Level`` Setting
72
72
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73
73
74
74
The ``LOG_LOCAL_LEVEL`` definition allows you to override the **maximum log level** for a specific source file or component without modifying the Kconfig options. It effectively sets the **maximum log level** locally, enabling or excluding specific logs in the binary.
@@ -105,13 +105,13 @@ Example: Set the log level to ``ERROR`` for all components (global setting):
105
105
106
106
Adjusting log output per module (tag) depends on :ref:`CONFIG_LOG_TAG_LEVEL_IMPL`, which is enabled by default. If this feature is not required, you can disable it to reduce code size and improve performance:
107
107
108
-
Example: Set the log level to ``WARNING`` only for the Wi-Fi component (module-specific setting).
108
+
Example: Set the log level to ``WARNING`` only for the Wi-Fi component (module-specific setting):
109
109
110
110
.. code-block:: c
111
111
112
112
esp_log_level_set("wifi", ESP_LOG_WARN);
113
113
114
-
Using Logging Library
114
+
Use Logging Library
115
115
---------------------
116
116
117
117
In each C file that uses the logging functionality, define the ``TAG`` variable.
@@ -203,7 +203,7 @@ The logging system supports the following formatting options, applicable for bot
203
203
- **System time (HH:MM:SS.sss)** `(14:31:18.532)`: Displays time in hours, minutes, seconds, and milliseconds.
204
204
- **System time (YY-MM-DD HH:MM:SS.sss)** `(2023-08-15 14:31:18.532)`: Similar to the above, but also includes the date.
205
205
- **Unix time in milliseconds** `(1692099078532)`: Displays Unix time in milliseconds.
206
-
- For **Log V2**, the :ref:`CONFIG_LOG_TIMESTAMP_SUPPORT` option enables runtime support for adding timestamp output to specific logs, files, or components, even if global timestamp is disabled. To enable the **Milliseconds since boot** timestamp for a specific context use ``ESP_LOG_TIMESTAMP_DISABLED``.
206
+
- For **Log V2**, the :ref:`CONFIG_LOG_TIMESTAMP_SUPPORT` option enables runtime support for adding timestamp output to specific logs, files, or components, even if global timestamp is disabled. To enable the **Milliseconds since boot** timestamp for a specific context, use ``ESP_LOG_TIMESTAMP_DISABLED``.
207
207
208
208
- **Tag**: Displays a user-defined identifier for the source module.
209
209
@@ -292,17 +292,17 @@ There are three settings that control the ability to change the log level at run
292
292
293
293
- Reducing memory consumption:
294
294
295
-
- **IRAM**: ~260 bytes
296
-
- **DRAM**: ~264 bytes
297
-
- **Flash**: ~1 KB
295
+
- **IRAM**: about 260 bytes
296
+
- **DRAM**: about 264 bytes
297
+
- **Flash**: about 1 KB
298
298
299
299
- Boosting log operation performance by up to 10 times.
300
300
301
301
- **Tag-Level Checks** (:ref:`CONFIG_LOG_TAG_LEVEL_IMPL`, default **Cache + Linked List**): Determines how per-tag log level checks are performed, affecting memory usage and lookup speed:
- **Linked List**: Enables per-tag log level settings using a linked list-only implementation (no cache). This method searches through all tags in the linked list to determine the log level, which may result in slower lookups for a large number of tags but consumes less memory compared to the **cache** approach. The linked list approach performs full string comparisons of log tags to identify the appropriate log level. Unlike **Cache**, it does not rely on tag pointer comparisons, making it suitable for dynamic tag definitions. Select this option if you prioritize memory savings, need to enable or disable logs for specific modules, or want to use tags defined as variables. Selecting this option automatically enables **Dynamic Log Level Control**. The linked list entries are allocated on the heap during the execution of ``ESP_LOGx`` macros when a new tag is encountered.
305
+
- **Linked List**: Enables per-tag log level settings using a linked list-only implementation (no cache). This method searches through all tags in the linked list to determine the log level, which may result in slower lookups for a large number of tags but consumes less memory compared to the **Cache** approach. The linked list approach performs full string comparisons of log tags to identify the appropriate log level. Unlike **Cache**, it does not rely on tag pointer comparisons, making it suitable for dynamic tag definitions. Select this option if you prioritize memory savings, need to enable or disable logs for specific modules, or want to use tags defined as variables. Selecting this option automatically enables **Dynamic Log Level Control**. The linked list entries are allocated on the heap during the execution of ``ESP_LOGx`` macros when a new tag is encountered.
306
306
307
307
- **Cache + Linked List** (Default): It is a hybrid mode that combines caching with a **linked list** for log tag level checks. This hybrid approach offers a balance between speed and memory usage. The cache stores recently accessed log tags and their corresponding log levels, providing faster lookups for frequently used tags. The cache approach compares the tag pointers, which is faster than performing full string comparisons. For less frequently used tags, the **linked list** is utilized to search for the log level. This option may not work properly when dynamic tag definitions are used, as it relies on tag pointer comparisons in the cache, which are not suitable for dynamically defined tags. This hybrid approach improves the efficiency of log level retrieval by leveraging the speed of caching for common tags and the memory efficiency of a linked list for less frequently used tags. Selecting this option automatically enables **Dynamic Log Level Control**.
308
308
@@ -402,85 +402,136 @@ The logging system provides macros for logging buffer data. These macros can be
402
402
403
403
The number of lines in the output depends on the size of the buffer.
404
404
405
+
405
406
Performance and Measurements
406
407
----------------------------
407
408
408
409
When logging is used in a task, the task stack must be configured with at least 2 KB of space to ensure sufficient memory for logging operations.
409
410
410
411
The following measurements were performed using tests inside the log component with default settings (the maximum and default log levels were set to INFO, color support was disabled, without master log and timestamps were enabled) across different chips:
411
412
412
-
- ``Performance measurements for log APIs``.
413
-
- ``Stack usage for log APIs``.
413
+
- Performance measurements for log APIs
414
+
- Stack usage for log APIs
414
415
415
416
``esp_rom_printf`` and ``esp_rom_vprintf`` produce similar results. Similarly, ``vprintf`` and ``printf`` yield comparable outcomes. Hence, only one of each pair is included in the tables below.
416
417
417
-
**Stack Usage (bytes):**
418
-
419
-
+-------------------+-------+---------+---------+
420
-
| Function | ESP32 | ESP32C2 | ESP32C3 |
421
-
+===================+=======+=========+=========+
422
-
| esp_rom_printf | 128 | 192 | 192 |
423
-
+-------------------+-------+---------+---------+
424
-
| ESP_EARLY_LOGI V1 | 128 | 192 | 192 |
425
-
+-------------------+-------+---------+---------+
426
-
| ESP_EARLY_LOGI V2 | 336 | 324 | 324 |
427
-
+-------------------+-------+---------+---------+
428
-
| ESP_DRAM_LOGI V1 | 128 | 192 | 192 |
429
-
+-------------------+-------+---------+---------+
430
-
| ESP_DRAM_LOGI V2 | 336 | 324 | 324 |
431
-
+-------------------+-------+---------+---------+
432
-
| vprintf | 1168 | 384 | 1344 |
433
-
+-------------------+-------+---------+---------+
434
-
| ESP_LOGI V1 | 1184 | 384 | 1344 |
435
-
+-------------------+-------+---------+---------+
436
-
| ESP_LOGI V2 | 1152 | 592 | 1504 |
437
-
+-------------------+-------+---------+---------+
418
+
.. list-table:: Stack Usage (bytes)
419
+
:header-rows: 1
420
+
421
+
* - Function
422
+
- ESP32
423
+
- ESP32C2
424
+
- ESP32C3
425
+
* - esp_rom_printf
426
+
- 128
427
+
- 192
428
+
- 192
429
+
* - ESP_EARLY_LOGI V1
430
+
- 128
431
+
- 192
432
+
- 192
433
+
* - ESP_EARLY_LOGI V2
434
+
- 336
435
+
- 324
436
+
- 324
437
+
* - ESP_DRAM_LOGI V1
438
+
- 128
439
+
- 192
440
+
- 192
441
+
* - ESP_DRAM_LOGI V2
442
+
- 336
443
+
- 324
444
+
- 324
445
+
* - vprintf
446
+
- 1168
447
+
- 384
448
+
- 1344
449
+
* - ESP_LOGI V1
450
+
- 1184
451
+
- 384
452
+
- 1344
453
+
* - ESP_LOGI V2
454
+
- 1152
455
+
- 592
456
+
- 1504
438
457
439
458
The stack usage differences between **Log V1** and **Log V2** are negligible.
440
459
441
-
**Performance (without output in microseconds):**
442
-
443
-
+-------------------+-------+---------+---------+
444
-
| Function | ESP32 | ESP32C2 | ESP32C3 |
445
-
+===================+=======+=========+=========+
446
-
| esp_rom_printf | 1 | 2 | 1 |
447
-
+-------------------+-------+---------+---------+
448
-
| ESP_EARLY_LOGI V1 | 15 | 24 | 14 |
449
-
+-------------------+-------+---------+---------+
450
-
| ESP_EARLY_LOGI V2 | 28 | 36 | 25 |
451
-
+-------------------+-------+---------+---------+
452
-
| ESP_DRAM_LOGI V1 | 6 | 9 | 5 |
453
-
+-------------------+-------+---------+---------+
454
-
| ESP_DRAM_LOGI V2 | 19 | 22 | 14 |
455
-
+-------------------+-------+---------+---------+
456
-
| vprintf | 15 | 9 | 7 |
457
-
+-------------------+-------+---------+---------+
458
-
| ESP_LOGI V1 | 27 | 16 | 12 |
459
-
+-------------------+-------+---------+---------+
460
-
| ESP_LOGI V2 | 77 | 54 | 40 |
461
-
+-------------------+-------+---------+---------+
460
+
.. list-table:: Performance (without output in microseconds)
461
+
:header-rows: 1
462
+
463
+
* - Function
464
+
- ESP32
465
+
- ESP32C2
466
+
- ESP32C3
467
+
* - esp_rom_printf
468
+
- 1
469
+
- 2
470
+
- 1
471
+
* - ESP_EARLY_LOGI V1
472
+
- 15
473
+
- 24
474
+
- 14
475
+
* - ESP_EARLY_LOGI V2
476
+
- 28
477
+
- 36
478
+
- 25
479
+
* - ESP_DRAM_LOGI V1
480
+
- 6
481
+
- 9
482
+
- 5
483
+
* - ESP_DRAM_LOGI V2
484
+
- 19
485
+
- 22
486
+
- 14
487
+
* - vprintf
488
+
- 15
489
+
- 9
490
+
- 7
491
+
* - ESP_LOGI V1
492
+
- 27
493
+
- 16
494
+
- 12
495
+
* - ESP_LOGI V2
496
+
- 77
497
+
- 54
498
+
- 40
462
499
463
500
If logging to UART is measured, the performance numbers for **Log V1** and **Log V2** are nearly identical. The slight differences in processing overhead introduced by **Log V2** become negligible compared to the time it takes to send logs over UART. Thus, in most practical use cases, the performance impact of switching to **Log V2** will be unnoticeable.
464
501
465
-
**Memory Usage (bytes):**
502
+
**Memory Usage (bytes)**
466
503
467
504
The following measurements were performed using the ``esp_timer`` example with default settings for ESP32: the maximum and default log levels were set to INFO, color support was disabled, and timestamps were enabled. After enabling the **Log V2** option, the example was rebuilt, and the memory usage differences were compared using the command:
0 commit comments