Skip to content

feat: set log level in runtime#66

Merged
erhankur merged 1 commit intomasterfrom
add_log_level_setting
Feb 19, 2026
Merged

feat: set log level in runtime#66
erhankur merged 1 commit intomasterfrom
add_log_level_setting

Conversation

@erhankur
Copy link
Collaborator

This PR adds configurable log-level control for esp-stub-lib from both application code and build configuration.

@github-actions
Copy link

github-actions bot commented Feb 18, 2026

Messages
📖 🎉 Good Job! All checks are passing!

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


Click to see more instructions ...


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

DangerJS is triggered with each push 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 is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions 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 against 6df67f1

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds runtime-configurable log level control to esp-stub-lib, allowing applications to adjust verbosity dynamically through both the build configuration (STUB_LIB_LOG_LEVEL) and runtime API calls.

Changes:

  • Introduces a new stub_lib_log_level_t enum with levels from NONE to VERBOSE (V)
  • Adds runtime log level management through new public API functions
  • Refactors logging macros to support conditional logging based on runtime level

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
include/esp-stub-lib/log.h Adds log level enum type, new public API functions for log level control, and refactors logging macros to check runtime level
src/log_common.c Implements log level management with normalization, getter, and setter functions
src/log_uart.c Renames stub_lib_log_init() to stub_lib_log_backend_init() to separate backend initialization from level configuration
src/log_buf.c Renames stub_lib_log_init() to stub_lib_log_backend_init() for consistency with log_uart.c
example/stub_main.c Demonstrates the new API by passing initial log level to STUB_LOG_INIT and changing level at runtime

@erhankur erhankur force-pushed the add_log_level_setting branch from 08118ef to 6df67f1 Compare February 18, 2026 20:27
@erhankur erhankur requested a review from Dzarda7 February 18, 2026 20:28
@Dzarda7
Copy link
Collaborator

Dzarda7 commented Feb 18, 2026

LGTM, thanks, nice improvement.Just out of curiosity, you need to be able to change log verbosity during runtime?

Just so you know, I plan to implement possibility to set output channel for logging (UART0,1, USB-Serial-JTAG), which will be really useful for us. So we might need to add new parameter to the stub_lib_log_init in the future. Before this, we need to use custom implementation of all tx_one_char functions instead of ROM as it has some bug for esp32s3 causing slowdowns and these functions tends to send data to multiple channels which does not work for us. This is already resolved for USB-Serial-JTAG, but I need to change this for UART too, just so you know what I plan to do in the future. This way we can simply debug our stub.

@erhankur
Copy link
Collaborator Author

LGTM, thanks, nice improvement.Just out of curiosity, you need to be able to change log verbosity during runtime?

We need different log levels. Some logs are verbose and not critical to see all the time. However, when needed, we should be able to increase the log level from OpenOCD without rebuilding the stub code.

Just so you know, I plan to implement possibility to set output channel for logging (UART0,1, USB-Serial-JTAG), which will be really useful for us. So we might need to add new parameter to the stub_lib_log_init in the future. Before this, we need to use custom implementation of all tx_one_char functions instead of ROM as it has some bug for esp32s3 causing slowdowns and these functions tends to send data to multiple channels which does not work for us. This is already resolved for USB-Serial-JTAG, but I need to change this for UART too, just so you know what I plan to do in the future. This way we can simply debug our stub.

Will be a nice improvement.

@erhankur
Copy link
Collaborator Author

@Dzarda7 Thank you for the quick review.

@erhankur erhankur merged commit ee158e0 into master Feb 19, 2026
30 checks passed
@erhankur erhankur deleted the add_log_level_setting branch February 19, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants