Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(logging): Arduino log redirection#11159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
me-no-dev merged 8 commits intoespressif:masterfrommathieucarbou:log-redirect
Apr 14, 2025

Conversation

@mathieucarbou
Copy link
Contributor

@mathieucarboumathieucarbou commentedMar 21, 2025
edited
Loading

ets_sys.h supports log redirection whenets_printf() is used and some functions are set withets_install_putc1() orets_install_putc1().

/**  * @brief  Printf the strings to uart or other devices, similar with printf, simple than printf.  *         Can not print float point data format, or longlong data format.  *         So we maybe only use this in ROM.  *  * @param  const char *fmt : See printf.  *  * @param  ... : See printf.  *  * @return int : the length printed to the output device.*/intets_printf(constchar *fmt, ...);/**  * @brief  Output a char to uart, which uart to output(which is in uart module in ROM) is not in scope of the function.  *         Can not print float point data format, or longlong data format  *  * @param  char c : char to output.  *  * @return None*/voidets_write_char_uart(char c);/**  * @brief  Ets_printf have two output functions: putc1 and putc2, both of which will be called if need ouput.  *         To install putc1, which is defaulted installed as ets_write_char_uart in none silent boot mode, as NULL in silent mode.  *  * @param  void (*)(char) p: Output function to install.  *  * @return None*/voidets_install_putc1(void (*p)(char c));/**  * @brief  Ets_printf have two output functions: putc1 and putc2, both of which will be called if need ouput.  *         To install putc2, which is defaulted installed as NULL.  *  * @param  void (*)(char) p: Output function to install.  *  * @return None*/voidets_install_putc2(void (*p)(char c));

I need to add a customets_install_putc1() handler to redirect arduino logs, but sadly the implementation inesp32-hal-uart.c is bypassing theets_printf() internal mechanism and is directly callingets_write_char_uart() instead .

#if (ARDUINO_USB_CDC_ON_BOOT==1&&ARDUINO_USB_MODE==0)||CONFIG_IDF_TARGET_ESP32C3 \
|| ((CONFIG_IDF_TARGET_ESP32H2||CONFIG_IDF_TARGET_ESP32C6||CONFIG_IDF_TARGET_ESP32P4)&&ARDUINO_USB_CDC_ON_BOOT==1)
vsnprintf(temp,len+1,format,arg);
ets_printf("%s",temp);
#else
intwlen=vsnprintf(temp,len+1,format,arg);
for (inti=0;i<wlen;i++) {
ets_write_char_uart(temp[i]);
}
#endif

Why ? I really was not able to figure out...

But this piece of code prevents everybody from redirecting Arduino logs, except with the boards in the macro conditions listed above...

Since I do not know the logic whyets_printf() is not called in all cases, I am proposing to add a macro:ARDUINO_LOG_FORCE_ETS_PRINTF=1 which, when set, will make sure all the logs go throughets_printf().

The user setting this macro will then be responsible to:

  1. Either callets_install_putc1(ets_write_char_uart)
  2. Or callets_install_putc1(my_custom_character_log_callback) with his custom function to redirect the logs.

Use case example:

static StreamString* _arduinoLogBuffer =nullptr;static Mycila::Logger* _arduinoLogDestination =nullptr;staticvoidlog_char(char c) {if (!_arduinoLogDestination)return;  _arduinoLogBuffer->write(c);if (c =='\n') {for (auto& output : _arduinoLogDestination->_outputs) {      output->print("SYSTEM:");// TODO: REMOVE THIS - PROVES ARDUINO LOGS WERE REDIRECTD      output->print(*_arduinoLogBuffer);    }    _arduinoLogBuffer->clear();  }}staticvoidredirectArduinoLogs(Logger& logger) {  _arduinoLogBuffer =newStreamString();  _arduinoLogBuffer->reserve(MYCILA_LOGGER_BUFFER_SIZE);  _arduinoLogDestination = &logger;// will override default arduino installed functions which sends logs to UARTets_install_putc1(log_char);}

With the macro def and the code above Arduino logs with be printed:

redirectArduinoLogs(logger);  logger.setLevel(ARDUHAL_LOG_LEVEL_DEBUG);  logger.forwardTo(Serial);log_d("Arduino debug message");log_i("Arduino info message");log_w("Arduino warning message");log_e("Arduino error message");

outputs:

SYSTEM: [   819][D][Logger.ino:17] setup(): Arduino debug messageSYSTEM: [   826][I][Logger.ino:18] setup(): Arduino info messageSYSTEM: [   833][W][Logger.ino:19] setup(): Arduino warning messageSYSTEM: [   840][E][Logger.ino:20] setup(): Arduino error message

@github-actions
Copy link
Contributor

github-actionsbot commentedMar 21, 2025
edited
Loading

Messages
📖🎉 Good Job! All checks are passing!

👋Hello mathieucarbou, we appreciate your contribution to this project!


📘 Please review the project'sContributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you haveread and signed theContributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by thePR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with eachpush event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger isnot a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manuallyretry these Danger checks, please navigate to theActions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫dangerJS against7014b39

@lucasssvazlucasssvaz added the Peripheral: UARTRelated to the UART peripheral or its functionality. labelMar 21, 2025
@mathieucarboumathieucarbou changed the titlefeat(log) Support redirecting Arduino logsfeat(logging): Arduino log redirectionMar 21, 2025
@SuGlider
Copy link
Collaborator

@mathieucarbou - I remember that the reason for that is because ESP32|ESP32-S2|ESP32-S3 (Xtensa SoC) had a problem withets_printf(). This code works for UART and also USB CDC logging, whenSerial is actually a HWSerial or USBCDC port.

We can review if this is still valid.

@SuGlider
Copy link
Collaborator

@mathieucarbou - What SoC do you use with your projects?

@mathieucarbou
Copy link
ContributorAuthor

mathieucarbou commentedMar 21, 2025
edited
Loading

@mathieucarbou - What SoC do you use with your projects?

I am currently testing with an esp32dev board, but the project has to also work for some other boards such as s2, s3, wt32_eth01, etc. This is a feature that will only be activated in debug mode to grab the boot logs from the ESP since users cannot connect easily to a USB computer.

I did the modification locally in the c file and tested with the esp32dev board and it works but I don't know the possible impact of this on other boards.

I was also intrigued by this comment in the header:

To install putc1, which is defaulted installed as ets_write_char_uart

So this is my understanding that putc1 (so a call to ets_printf) should already use ets_write_char_uart behind ?

Copy link
Collaborator

@SuGliderSuGlider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'll retest log output within all SoC using justets_printf() to verify if it works for all possible Serial ports (UART/CDC).

Let set this PR on hold until the results are out.

mathieucarbou reacted with heart emoji
@github-actions
Copy link
Contributor

github-actionsbot commentedMar 21, 2025
edited
Loading

Test Results

 76 files   76 suites   12m 44s ⏱️
 38 tests  38 ✅ 0 💤 0 ❌
241 runs  241 ✅ 0 💤 0 ❌

Results for commit7014b39.

♻️ This comment has been updated with latest results.

@mathieucarbou
Copy link
ContributorAuthor

I'll retest log output within all SoC using justets_printf() to verify if it works for all possible Serial ports (UART/CDC).

Let set this PR on hold until the results are out.

Thanks a lot!

@SuGliderSuGlider self-assigned thisMar 21, 2025
@SuGlider
Copy link
Collaborator

SuGlider commentedMar 21, 2025
edited
Loading

So this is my understanding that putc1 (so a call to ets_printf) should already use ets_write_char_uart behind ?

ets_install_putc1() andets_install_putc2() should just define a pointer to a function that shall output anything that usesets_printf(). In other words,ets_printf() calls the output function defined asputc1() orputc2().

Therefore, if your software needs to redirect log output, it could just change the function pointed byets_install_putc1() for UART andets_install_putc2() for USB CDC and useets_printf() whenever logging.

ets_write_char_uart() outputs a single byte using exclusivly the UART peripheral - internal ROM implementation used by the system for outputting messages, such as when pressing BOOT and pulsing RESET to enter in BOOT mode.

@mathieucarbou
Copy link
ContributorAuthor

mathieucarbou commentedMar 21, 2025
edited
Loading

ets_install_putc1() andets_install_putc2() should just define a pointer to a function that shall output anything that usesets_printf(). In other words,ets_printf() calls the output function defined asputc1() orputc2().

That's exactly my understanding also.

Therefore, if your software needs to redirect log output, it could just change the function pointed byets_install_putc1() for UART andets_install_putc2() for USB CDC and useets_printf() whenever logging.

That's what does not work.

If you mean:

if your software needs to redirect log outputwhen usingets_printf()

then I agree with you.

But this is not the use case explained above.

What I want and need is to redirect all calls to log_e, log_w, log_i, etc Basically, all Arduino logs, to a custom function. And for that, Arduino would need to callevery timeets_printf(), which is not the case now because it directly calls instead the uart callback.

@github-actions
Copy link
Contributor

github-actionsbot commentedMar 21, 2025
edited
Loading

Memory usage test (comparing PR against master branch)

The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.

MemoryFLASH [bytes]FLASH [%]RAM [bytes]RAM [%]
TargetDECINCDECINCDECINCDECINC
ESP32P4💚 -1000.000.00000.000.00
ESP32S3💚 -16⚠️ +1400.00⚠️ +0.04000.000.00
ESP32S2💚 -400.000.00000.000.00
ESP32C30⚠️ +2220.00⚠️ +0.07000.000.00
ESP32C6💚 -10⚠️ +2140.00⚠️ +0.08000.000.00
ESP32H2💚 -10⚠️ +2080.00⚠️ +0.07000.000.00
ESP32💚 -48⚠️ +4💚 -0.010.00000.000.00
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32P4ESP32S3ESP32S2ESP32C3ESP32C6ESP32H2ESP32
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
ArduinoOTA/examples/BasicOTA💚 -100💚 -40💚 -4000💚 -100--💚 -160
AsyncUDP/examples/AsyncUDPClient💚 -100💚 -400000💚 -100--💚 -160
AsyncUDP/examples/AsyncUDPMulticastServer💚 -100💚 -40💚 -4000💚 -100--⚠️ +40
AsyncUDP/examples/AsyncUDPServer💚 -100💚 -40💚 -4000💚 -100--💚 -160
DNSServer/examples/CaptivePortal💚 -100💚 -40💚 -4000💚 -100--💚 -160
EEPROM/examples/eeprom_class💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
EEPROM/examples/eeprom_extra💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
EEPROM/examples/eeprom_write💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/AnalogOut/LEDCFade💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/AnalogOut/LEDCSingleChannel💚 -100💚 -400000💚 -100💚 -10000
ESP32/examples/AnalogOut/LEDCSoftwareFade💚 -100💚 -400000💚 -100💚 -10000
ESP32/examples/AnalogOut/SigmaDelta💚 -100💚 -400000💚 -100💚 -10000
ESP32/examples/AnalogOut/ledcFrequency💚 -100💚 -400000💚 -100💚 -10000
ESP32/examples/AnalogOut/ledcWrite_RGB💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/AnalogRead💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/AnalogReadContinuous💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/ArduinoStackSize💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/CI/CIBoardsTest💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/ChipID/GetChipID💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/DeepSleep/TimerWakeUp💚 -100💚 -40💚 -4000💚 -100--💚 -160
ESP32/examples/DeepSleep/TouchWakeUp💚 -100💚 -40💚 -40------💚 -160
ESP32/examples/FreeRTOS/BasicMultiThreading💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/FreeRTOS/Mutex💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/FreeRTOS/Queue💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/FreeRTOS/Semaphore💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/GPIO/BlinkRGB💚 -100💚 -400000💚 -100💚 -10000
ESP32/examples/GPIO/FunctionalInterrupt💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/GPIO/FunctionalInterruptStruct💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/GPIO/GPIOInterrupt💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/HWCDC_Events💚 -100⚠️ +1400--⚠️ +2220⚠️ +2140⚠️ +2080--
ESP32/examples/MacAddress/GetMacAddress💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/RMT/Legacy_RMT_Driver_Compatible💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/RMT/RMTCallback💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/RMT/RMTLoopback💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/RMT/RMTReadXJT💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/RMT/RMTWrite_RGB_LED💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/RMT/RMT_CPUFreq_Test💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/RMT/RMT_EndOfTransmissionState💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/RMT/RMT_LED_Blink💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/ResetReason/ResetReason💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/ResetReason/ResetReason2💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Serial/BaudRateDetect_Demo💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Serial/OnReceiveError_BREAK_Demo💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Serial/OnReceive_Demo💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Serial/RS485_Echo_Demo💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Serial/RxFIFOFull_Demo💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Serial/RxTimeout_Demo💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Serial/Serial_All_CPU_Freqs💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Serial/Serial_STD_Func_OnReceive💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Serial/onReceiveExample💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/TWAI/TWAIreceive💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/TWAI/TWAItransmit💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Template/ExampleTemplate💚 -100💚 -400000💚 -100💚 -10000
ESP32/examples/Time/SimpleTime💚 -100💚 -40💚 -4000💚 -100--💚 -160
ESP32/examples/Timer/RepeatTimer💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Timer/WatchdogTimer💚 -100000000💚 -100💚 -100💚 -200
ESP32/examples/Touch/TouchInterrupt💚 -100💚 -40💚 -40------💚 -160
ESP32/examples/Touch/TouchRead💚 -100💚 -40💚 -40------💚 -160
ESP32/examples/Utilities/HEXBuilder💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Utilities/MD5Builder💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP32/examples/Utilities/SHA1Builder💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP_I2S/examples/ES8388_loopback💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESP_I2S/examples/Record_to_WAV💚 -100💚 -40--------💚 -160
ESP_I2S/examples/Simple_tone💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
ESPmDNS/examples/mDNS-SD_Extended💚 -100💚 -160💚 -4000💚 -100--💚 -160
ESPmDNS/examples/mDNS_Web_Server💚 -100000000💚 -100--💚 -160
Ethernet/examples/ETH_TLK110💚 -100----------💚 -160
Ethernet/examples/ETH_W5500_Arduino_SPI💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
Ethernet/examples/ETH_W5500_IDF_SPI💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
Ethernet/examples/ETH_WIFI_BRIDGE💚 -100💚 -40💚 -4000💚 -100--00
FFat/examples/FFat_Test💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
FFat/examples/FFat_time💚 -100💚 -40💚 -4000💚 -100--💚 -160
HTTPClient/examples/Authorization💚 -100💚 -40💚 -4000💚 -100--💚 -200
HTTPClient/examples/BasicHttpClient💚 -100⚠️ +40💚 -4000💚 -100--💚 -160
HTTPClient/examples/BasicHttpsClient💚 -100💚 -400000💚 -100--💚 -160
HTTPClient/examples/ReuseConnection💚 -100💚 -40💚 -4000💚 -100--💚 -160
HTTPClient/examples/StreamHttpClient💚 -100💚 -40💚 -4000💚 -100--💚 -160
HTTPUpdate/examples/httpUpdate💚 -100💚 -40💚 -4000💚 -100--💚 -160
HTTPUpdate/examples/httpUpdateSPIFFS💚 -100💚 -40💚 -4000💚 -100--💚 -160
HTTPUpdate/examples/httpUpdateSecure💚 -100💚 -40💚 -4000💚 -100--💚 -160
HTTPUpdateServer/examples/WebUpdater💚 -100💚 -40💚 -4000💚 -100--💚 -160
LittleFS/examples/LITTLEFS_test💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
LittleFS/examples/LITTLEFS_time💚 -100💚 -40💚 -4000💚 -100--💚 -160
NetBIOS/examples/ESP_NBNST💚 -100💚 -40💚 -4000💚 -100--💚 -160
NetworkClientSecure/examples/WiFiClientInsecure💚 -100💚 -400000💚 -100--💚 -160
NetworkClientSecure/examples/WiFiClientPSK💚 -100💚 -40💚 -4000💚 -100--💚 -160
NetworkClientSecure/examples/WiFiClientSecure💚 -100💚 -40💚 -4000💚 -100--💚 -160
NetworkClientSecure/examples/WiFiClientSecureProtocolUpgrade💚 -100💚 -40💚 -4000💚 -100--💚 -160
NetworkClientSecure/examples/WiFiClientShowPeerCredentials💚 -100💚 -40💚 -4000💚 -100--💚 -160
NetworkClientSecure/examples/WiFiClientTrustOnFirstUse💚 -100💚 -400000💚 -100--💚 -160
PPP/examples/PPP_Basic💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
PPP/examples/PPP_WIFI_BRIDGE💚 -100💚 -40💚 -4000💚 -100--💚 -160
Preferences/examples/Prefs2Struct💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
Preferences/examples/StartCounter💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
SD/examples/SD_Test💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
SD/examples/SD_time💚 -100💚 -40💚 -4000💚 -100--💚 -160
SD_MMC/examples/SD2USBMSC💚 -100💚 -40----------
SD_MMC/examples/SDMMC_Test💚 -100💚 -40--------💚 -160
SD_MMC/examples/SDMMC_time💚 -100💚 -40--------💚 -160
SPI/examples/SPI_Multiple_Buses💚 -100💚 -400000💚 -100💚 -10000
SPIFFS/examples/SPIFFS_Test💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
SPIFFS/examples/SPIFFS_time💚 -100💚 -40💚 -4000💚 -100--💚 -160
TFLiteMicro/examples/hello_world💚 -100💚 -400000💚 -100💚 -10000
Ticker/examples/Blinker💚 -100💚 -400000💚 -100💚 -10000
Ticker/examples/TickerBasic💚 -100💚 -400000💚 -100💚 -10000
Ticker/examples/TickerParameter💚 -100💚 -400000💚 -100💚 -10000
USB/examples/CompositeDevice💚 -100💚 -40💚 -40--------
USB/examples/ConsumerControl💚 -100💚 -4000--------
USB/examples/CustomHIDDevice💚 -100💚 -40💚 -40--------
USB/examples/FirmwareMSC💚 -100💚 -40💚 -40--------
USB/examples/Gamepad💚 -100💚 -40💚 -40--------
USB/examples/HIDVendor💚 -100💚 -40💚 -40--------
USB/examples/Keyboard/KeyboardLogout💚 -100💚 -4000--------
USB/examples/Keyboard/KeyboardMessage💚 -100💚 -4000--------
USB/examples/Keyboard/KeyboardReprogram💚 -100💚 -4000--------
USB/examples/Keyboard/KeyboardSerial💚 -100💚 -40💚 -40--------
USB/examples/KeyboardAndMouseControl💚 -100💚 -40💚 -40--------
USB/examples/MIDI/MidiController💚 -100💚 -40💚 -40--------
USB/examples/MIDI/MidiInterface💚 -100💚 -40💚 -40--------
USB/examples/MIDI/MidiMusicBox💚 -100💚 -40💚 -40--------
USB/examples/MIDI/ReceiveMidi💚 -100💚 -40💚 -40--------
USB/examples/Mouse/ButtonMouseControl💚 -100💚 -4000--------
USB/examples/SystemControl💚 -100💚 -4000--------
USB/examples/USBMSC💚 -100💚 -40💚 -40--------
USB/examples/USBSerial💚 -100💚 -40💚 -40--------
USB/examples/USBVendor💚 -100💚 -40💚 -40--------
Update/examples/AWS_S3_OTA_Update💚 -100💚 -40💚 -4000💚 -100--💚 -160
Update/examples/HTTPS_OTA_Update💚 -100💚 -40💚 -4000💚 -100--💚 -160
Update/examples/HTTP_Client_AES_OTA_Update💚 -100💚 -40💚 -4000💚 -100--💚 -160
Update/examples/HTTP_Server_AES_OTA_Update💚 -100💚 -40💚 -4000💚 -100--💚 -160
Update/examples/OTAWebUpdater💚 -100💚 -40💚 -4000💚 -100--💚 -160
Update/examples/SD_Update💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
WebServer/examples/AdvancedWebServer💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/FSBrowser💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/Filters💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/HelloServer💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/HttpAdvancedAuth💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/HttpAuthCallback💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/HttpAuthCallbackInline💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/HttpBasicAuth💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/HttpBasicAuthSHA1💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/HttpBasicAuthSHA1orBearerToken💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/MultiHomedServers💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/PathArgServer💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/SDWebServer💚 -100💚 -400000💚 -100--💚 -160
WebServer/examples/SimpleAuthentification💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/UploadHugeFile💚 -100💚 -40💚 -4000💚 -100--💚 -160
WebServer/examples/WebServer💚 -100💚 -40💚 -4000💚 -100--💚 -200
WebServer/examples/WebUpdate💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/FTM/FTM_Initiator💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/FTM/FTM_Responder💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/SimpleWiFiServer💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiAccessPoint💚 -10000💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiClient💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiClientBasic💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiClientConnect💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiClientEvents💚 -10000💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiClientStaticIP💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiExtender💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiIPv6💚 -100⚠️ +40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiMulti💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiMultiAdvanced💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiScan💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiScanAsync💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiScanDualAntenna💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiScanTime💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiTelnetToSerial💚 -100💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiUDPClient💚 -100💚 -400000💚 -100--💚 -160
Wire/examples/WireMaster💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
Wire/examples/WireScan💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
Wire/examples/WireSlave💚 -100💚 -40💚 -4000💚 -100💚 -100💚 -160
BLE/examples/BLE5_extended_scan--💚 -40--00💚 -100💚 -100--
BLE/examples/BLE5_multi_advertising--💚 -40--00💚 -100💚 -100--
BLE/examples/BLE5_periodic_advertising--💚 -40--00💚 -100💚 -100--
BLE/examples/BLE5_periodic_sync--💚 -40--00💚 -100💚 -100--
BLE/examples/Beacon_Scanner--💚 -40--00💚 -100💚 -100💚 -160
BLE/examples/Client--00--00💚 -100💚 -100💚 -160
BLE/examples/EddystoneTLM_Beacon--💚 -40--00💚 -100💚 -100💚 -160
BLE/examples/EddystoneURL_Beacon--💚 -40--00💚 -100💚 -100💚 -160
BLE/examples/Notify--💚 -40--00💚 -100💚 -100💚 -160
BLE/examples/Scan--💚 -40--00💚 -100💚 -100💚 -160
BLE/examples/Server--💚 -120--00💚 -100💚 -100💚 -160
BLE/examples/Server_multiconnect--💚 -40--00💚 -100💚 -10000
BLE/examples/UART--💚 -40--00💚 -100💚 -100💚 -160
BLE/examples/Write--💚 -40--00💚 -100💚 -100💚 -160
BLE/examples/iBeacon--💚 -40--00💚 -100💚 -100💚 -160
ESP32/examples/Camera/CameraWebServer (1)--💚 -40💚 -40------00
ESP32/examples/Camera/CameraWebServer (2)--💚 -40💚 -40------💚 -200
ESP32/examples/Camera/CameraWebServer (3)--💚 -40----------
ESP32/examples/DeepSleep/ExternalWakeUp--💚 -40💚 -40------💚 -160
ESP_NOW/examples/ESP_NOW_Broadcast_Master--000000💚 -100--💚 -160
ESP_NOW/examples/ESP_NOW_Broadcast_Slave--💚 -40💚 -4000💚 -100--💚 -160
ESP_NOW/examples/ESP_NOW_Network--💚 -40💚 -4000💚 -100--💚 -160
ESP_NOW/examples/ESP_NOW_Serial--💚 -40💚 -4000💚 -100--💚 -160
ESP_SR/examples/Basic--💚 -40----------
HTTPClient/examples/HTTPClientEnterprise--💚 -40💚 -4000💚 -100--💚 -160
Insights/examples/DiagnosticsSmokeTest--💚 -40💚 -4000💚 -100--💚 -160
Insights/examples/MinimalDiagnostics--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterColorLight--💚 -40💚 -4000💚 -100--💚 -480
Matter/examples/MatterCommissionTest--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterComposedLights--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterContactSensor--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterDimmableLight--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterEnhancedColorLight--💚 -400000💚 -100--💚 -120
Matter/examples/MatterFan--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterHumiditySensor--00💚 -4000💚 -100--💚 -120
Matter/examples/MatterMinimum--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterOccupancySensor--00💚 -4000💚 -100--💚 -200
Matter/examples/MatterOnIdentify--00💚 -4000💚 -100--💚 -120
Matter/examples/MatterOnOffLight--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterOnOffPlugin--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterPressureSensor--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterSmartButon--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterTemperatureLight--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterTemperatureSensor--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/MatterThermostat--💚 -40💚 -4000💚 -100--💚 -160
Matter/examples/WiFiProvWithinMatter--💚 -400000💚 -100--💚 -160
NetworkClientSecure/examples/WiFiClientSecureEnterprise--💚 -40💚 -4000💚 -100--💚 -160
RainMaker/examples/RMakerCustom--💚 -40💚 -4000💚 -100----
RainMaker/examples/RMakerCustomAirCooler--💚 -40💚 -4000💚 -100----
RainMaker/examples/RMakerSonoffDualR3--💚 -40💚 -4000💚 -100----
RainMaker/examples/RMakerSwitch--💚 -40💚 -4000💚 -100----
SimpleBLE/examples/SimpleBleDevice--⚠️ +160--00💚 -100💚 -100💚 -160
WebServer/examples/Middleware--💚 -400000💚 -100--💚 -160
WiFi/examples/WPS--💚 -400000💚 -100--💚 -40
WiFi/examples/WiFiBlueToothSwitch--💚 -40--00💚 -100--💚 -200
WiFi/examples/WiFiClientEnterprise--💚 -40💚 -4000💚 -100--💚 -160
WiFi/examples/WiFiSmartConfig--💚 -40💚 -4000💚 -100--💚 -160
WiFiProv/examples/WiFiProv--000000💚 -100--💚 -160
Zigbee/examples/Zigbee_Color_Dimmer_Switch--💚 -40💚 -4000💚 -100💚 -100💚 -200
Zigbee/examples/Zigbee_Gateway--💚 -40💚 -4000----💚 -160
Zigbee/examples/Zigbee_On_Off_Switch--💚 -40💚 -4000💚 -100💚 -100💚 -160
Zigbee/examples/Zigbee_Range_Extender--💚 -40💚 -4000💚 -100💚 -100💚 -160
Zigbee/examples/Zigbee_Thermostat--💚 -40💚 -4000💚 -100💚 -100💚 -160
OpenThread/examples/COAP/coap_lamp--------💚 -100💚 -100--
OpenThread/examples/COAP/coap_switch--------💚 -100💚 -100--
OpenThread/examples/SimpleCLI--------💚 -100💚 -100--
OpenThread/examples/SimpleNode--------💚 -100💚 -100--
OpenThread/examples/SimpleThreadNetwork/ExtendedRouterNode--------💚 -100💚 -100--
OpenThread/examples/SimpleThreadNetwork/LeaderNode--------💚 -100💚 -100--
OpenThread/examples/SimpleThreadNetwork/RouterNode--------💚 -100💚 -100--
OpenThread/examples/ThreadScan--------💚 -100💚 -100--
OpenThread/examples/onReceive--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Analog_Input_Output--------💚 -100💚 -100--
Zigbee/examples/Zigbee_CarbonDioxide_Sensor--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Color_Dimmable_Light--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Contact_Switch--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Dimmable_Light--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Illuminance_Sensor--------💚 -100💚 -100--
Zigbee/examples/Zigbee_OTA_Client--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Occupancy_Sensor--------💚 -100💚 -100--
Zigbee/examples/Zigbee_On_Off_Light--------💚 -100💚 -100--
Zigbee/examples/Zigbee_PM25_Sensor--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Pressure_Flow_Sensor--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Scan_Networks--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Temperature_Sensor--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Vibration_Sensor--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Wind_Speed_Sensor--------💚 -100💚 -100--
Zigbee/examples/Zigbee_Window_Covering--------💚 -100💚 -100--
BluetoothSerial/examples/DiscoverConnect------------💚 -160
BluetoothSerial/examples/GetLocalMAC------------💚 -160
BluetoothSerial/examples/SerialToSerialBT------------💚 -160
BluetoothSerial/examples/SerialToSerialBTM------------💚 -160
BluetoothSerial/examples/SerialToSerialBT_Legacy------------💚 -160
BluetoothSerial/examples/SerialToSerialBT_SSP------------💚 -160
BluetoothSerial/examples/bt_classic_device_discovery------------💚 -160
BluetoothSerial/examples/bt_remove_paired_devices------------💚 -160
ESP32/examples/DeepSleep/SmoothBlink_ULP_Code------------💚 -160
Ethernet/examples/ETH_LAN8720------------💚 -160

@SuGliderSuGlider added Status: Needs investigationWe need to do some research before taking next steps on this issue Status: In Progress ⚠️Issue is in progress labelsMar 22, 2025
@SuGliderSuGlider moved this fromTodo toSelected for Development inArduino ESP32 Core Project RoadmapMar 31, 2025
@SuGliderSuGlider added this to the3.2.1 milestoneMar 31, 2025
@SuGlider
Copy link
Collaborator

@mathieucarbou - We will changeesp32-hal-uart.c to only useets_printf().

@SuGliderSuGlider removed the Status: In Progress ⚠️Issue is in progress labelApr 5, 2025
@SuGliderSuGlider added Status: Review neededIssue or PR is awaiting review and removed Status: Needs investigationWe need to do some research before taking next steps on this issue labelsApr 5, 2025
@SuGliderSuGlider moved this fromSelected for Development toIn Review inArduino ESP32 Core Project RoadmapApr 5, 2025
@mathieucarbou
Copy link
ContributorAuthor

@SuGlider : thanks a lot !

SuGlider reacted with heart emoji

@me-no-devme-no-dev added Status: Pending MergePull Request is ready to be merged and removed Status: Review neededIssue or PR is awaiting review labelsApr 9, 2025
@me-no-devme-no-dev merged commit60c8206 intoespressif:masterApr 14, 2025
57 checks passed
@mathieucarbou
Copy link
ContributorAuthor

mathieucarbou commentedJul 3, 2025
edited
Loading

Hello,

Just wanted to to drop a note that I was able to verify the feature in my application logger implementation (https://github.com/mathieucarbou/MycilaLogger)

#include<Arduino.h>#include<MycilaLogger.h>#include<StreamString.h>Mycila::Logger logger;StreamString logBuffer;voidsetup() {  Serial.begin(115200);while (!Serial)continue;Mycila::Logger::redirectArduinoLogs(logger);  logger.setLevel(ARDUHAL_LOG_LEVEL_DEBUG);  logger.forwardTo(&logBuffer);log_d("Arduino debug message");log_i("Arduino info message");log_w("Arduino warning message");log_e("Arduino error message");  Serial.println("Captured Arduino logs:");  Serial.println(logBuffer);  logBuffer.clear();  logger.debug("APP","A debug message");  logger.info("APP","An info message");  logger.warn("APP","A warning message");  logger.error("APP","An error message");  Serial.println("Captured Mycila logger logs:");  Serial.println(logBuffer);  logBuffer.clear();}voidloop() {delay(500);}

outputs:

image

That's a really super cool feature for apps with a non-dev user base in order to save the startup logs (up to a max amount) on disk when debug mode is activated in one's app.

I am using it like that:

Mycila::Logger logger;classLogStream :publicPrint {public:LogStream(constchar* path,size_t limit) : _path(path), _limit(limit) {      File file = LittleFS.open(_path,"r");      _logSize = file ? file.size() :0;      file.close();      _accepting = _logSize < _limit;    }size_twrite(constuint8_t* buffer,size_t size)override {if (!_accepting)return0;if (_logSize + size > _limit) {        _accepting =false;return0;      }      File file = LittleFS.open(_path,"a");if (!file)return0;size_t written = file.write(buffer, size);      file.close();      _logSize += written;return written;    }size_twrite(uint8_t c)override {assert(false);return0;    }private:constchar* _path;constsize_t _limit;size_t _logSize =0;bool _accepting =false;};[...]
logger.redirectArduinoLogs();logger.forwardTo(&Serial);// Serial outputlogger.forwardTo(webSerial);// WebSerial console at http://1.2.3.4/consolelogger.forwardTo(new LogStream(YASOLR_LOG_FILE,32 *1024));// first 32k of startup logs go on disk

Then I allow the user to download the startup logs for troubleshooting.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@me-no-devme-no-devme-no-dev approved these changes

@lucasssvazlucasssvazlucasssvaz approved these changes

@SuGliderSuGliderSuGlider approved these changes

@P-R-O-C-H-YP-R-O-C-H-YP-R-O-C-H-Y approved these changes

Assignees

@SuGliderSuGlider

Labels

Peripheral: UARTRelated to the UART peripheral or its functionality.Status: Pending MergePull Request is ready to be merged

Projects

Milestone

3.2.1

Development

Successfully merging this pull request may close these issues.

5 participants

@mathieucarbou@SuGlider@me-no-dev@lucasssvaz@P-R-O-C-H-Y

[8]ページ先頭

©2009-2025 Movatter.jp