Skip to content

Conversation

@thekurtovic
Copy link
Collaborator

  • This will allow NimBLE logging to be enabled without requiring IDF logging to be enabled.
  • Additionally this will allow for color codes to be customized for each log level.
  • Cleaned up preprocessor indentation style.

@thekurtovic
Copy link
Collaborator Author

thekurtovic commented Dec 5, 2024

WIP
I've had problems in the past when needing to enable debug level logging, since this normally depends on IDF logging.
There tends to be so much debug printing that it causes my board to go into a boot loop. I've been modifying NimBLELog.h locally to address this.
Also since I use ANSI color codes, I find it's difficult to distinguish my application logging vs NimBLE logging. I thought allowing for the colors to be customized would be helpful for parsing log output.

The kconfig part is a bit messy, but I'm not sure how else to go about it. I wanted to make it so that the log colors macros could be selected without requiring the if/elif color checks for each level. Let me know if there's a better way to do it.

@h2zero
Copy link
Owner

h2zero commented Dec 5, 2024

At first glance I think it's an interesting idea. I was thinking about overhauling the logging as well, I've removed quite a bit of it but better filtering is needed and the custom color idea is great. I'll look at this more in the next days but I have quite a bit on my agenda and want to publish a version 2 release before Christmas, so this might have to come after that.

@h2zero
Copy link
Owner

h2zero commented Dec 13, 2024

@thekurtovic Unfortunately this breaks the log filtering capability.
For your use have you tried the filtering options? i.e. :

  esp_log_level_set("*", ESP_LOG_ERROR);
  esp_log_level_set("NimBLEDevice", ESP_LOG_DEBUG);
  esp_log_level_set("NimBLEAdvertisedDevice", ESP_LOG_DEBUG);
  esp_log_level_set("NimBLEScan", ESP_LOG_DEBUG);

@thekurtovic
Copy link
Collaborator Author

This was meant to be an option which doesn't rely on esp logging, the loss of filtering would be a trade-off. Also wasn't aware you could even do that.
This seems pretty niche so I'll just close and make a patch file for my project.

@h2zero
Copy link
Owner

h2zero commented Dec 13, 2024

Unfortunately to change the colors we need to bypass the log filtering and that wouldn't be great. Here is some more info though, https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/log.html.

@thekurtovic
Copy link
Collaborator Author

The color part can still work with filtering like this.
a34ed8f

@h2zero
Copy link
Owner

h2zero commented Dec 14, 2024

@thekurtovic That looks good, have you tested it?

@thekurtovic
Copy link
Collaborator Author

Yes, tested on esp32-s3.
I've set log level to debug then tested with esp_log_level_set("*", ESP_LOG_WARN);.
Then tested setting nimble log levels like this.

esp_log_level_set("*", ESP_LOG_WARN);
esp_log_level_set("NimBLEScan", ESP_LOG_DEBUG);
esp_log_level_set("NimBLEClient", ESP_LOG_DEBUG);
esp_log_level_set("NimBLEDevice", ESP_LOG_DEBUG);
esp_log_level_set("NimBLEAdvertisedDevice", ESP_LOG_DEBUG);

@h2zero
Copy link
Owner

h2zero commented Dec 14, 2024

Perfect, please open a new PR or reopen this one and I will look to test/merge it after this release is done. Thanks for all the contributions!

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.

2 participants