Enable log levels in PlatformIO

esp32-hal-log.h defines macros for log output depending on levels. By default the log level is set to 0 (no log enabled). To use the log macros for different levels the log level can be set for a specific project in platformio.ini

Set log level for a specific project

Edit platformio.ini (located in the project folder) Add (or extend) the build_flags option:build_flags = -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG

Example platformio.ini:

Available levels:

  • Error
  • Warning
  • Info
  • Debug
  • Verbose
Facebooktwitterredditpinterestlinkedintumblrmail

3 comments

  • AZ

    Bernd, how can you control the level of logs per module ?

    Reply
    • beegee1962

      Not sure what you mean “by modules”. For the Arduino Framework you set log levels as described here and this setting is for all functions/libraries within the framework.

      If you want to set different log output for your code, please check my post ESP32 application log output in the same format as the core log output

      Reply
      • AZ

        Berndt,
        thank you for the reply.
        The my_log.h is a pretty good idea. thank you for sharing. With esp’s logging, With esp_log.h i can use esp_log_set_vprintf(). Is there a way to leverage it with your lib?

        Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Free Link Directory