EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1017 background imageLoading...
Page #1017 background image
Chapter 2. API Reference
Overview
The logging library provides two ways for setting log verbosity:
At compile time: in menuconfig, set the verbosity level using the option CONFIG_LOG_DEFAULT_LEVEL.
Optionally, also in menuconfig, set the maximum verbosity level using the option CON-
FIG_LOG_MAXIMUM_LEVEL. By default this is the same as the default level, but it can be set higher
in order to compile more otional logs into the firmware.
At runtime: all logs for verbosity levels lower than CONFIG_LOG_DEFAULT_LEVEL are enabled by default.
The function esp_log_level_set() can be used to set a logging level on a per module basis. Modules
are identified by their tags, which are human-readable ASCII zero-terminated strings.
There are the following verbosity levels:
Error (lowest)
Warning
Info
Debug
Verbose (highest)
Note: The function esp_log_level_set() cannot set logging levels higher than specified by CON-
FIG_LOG_MAXIMUM_LEVEL. To increase log level for a specific file above this maximum at compile time, use
the macro LOG_LOCAL_LEVEL (see the details below).
How to use this library
In each C file that uses logging functionality, define the TAG variable as shown below:
static const char* TAG = "MyModule";
Then use one of logging macros to produce output, e.g:
ESP_LOGW(TAG, "Baud rate error %.1f%%. Requested: %d baud, actual: %d baud", error
,* 100, baud_req, baud_real);
Several macros are available for different verbosity levels:
ESP_LOGE - error (lowest)
ESP_LOGW - warning
ESP_LOGI - info
ESP_LOGD - debug
ESP_LOGV - verbose (highest)
Additionally, there are ESP_EARLY_LOGx versions for each of these macros, e.g. ESP_EARLY_LOGE. These
versions have to be used explicitly in the early startup code only, before heap allocator and syscalls have been ini-
tialized. Normal ESP_LOGx macros can also be used while compiling the bootloader, but they will fall back to the
same implementation as ESP_EARLY_LOGx macros.
There are also ESP_DRAM_LOGx versions for each of these macros, e.g. ESP_DRAM_LOGE. These versions are
used in some places where logging may occur with interrupts disabled or with flash cache inaccessible. Use of this
macros should be as sparing as possible, as logging in these types of code should be avoided for performance reasons.
Note: Inside critical sections interrupts are disabled so its only possible to use ESP_DRAM_LOGx (preferred)
or ESP_EARLY_LOGx. Even though its possible to log in these situations, its better if your program can be
structured not to require it.
To override default verbosity level at file or component scope, define the LOG_LOCAL_LEVEL macro.
At file scope, define it before including esp_log.h, e.g.:
Espressif Systems 1006
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish