redirecting printf to ESP_LOGx
Posted: Fri Nov 08, 2019 8:05 pm
Hello - hopefully this is the right place for this question.
It seems the esp-idf Bluetooth library doesn't have much BT/RFCOMM support, so I'm starting to work on a Bluetooth implementation using Blue Kitchen's BTStack. BTStack is a third-party library that supports many hardware platforms, among them the esp32. I've got it working, but their library is rich with informational printf's that would be much better suited for ESP_LOGI() calls. The library is rather, uh, loquacious.
So, one solution would be to go through all of their code and manually change printfs to ESP_LOGI calls, but that's a lot of code to change and I'd have to redo it every time the library gets updated. Or I could try to write a little .h file with a macro redefining printf to an ESP_LOGI wrapper using some VA_ARGS magic. I'd still have to touch every module, but at least it would just be a header file include.
But the cleanest solution would be to somehow hijack the esp32 printf library function, assuming it's not needed elsewhere or by ESP_LOG itself. I'm wondering if anyone has run into this or a similar issue before, and how they solved it.
Ideas?
It seems the esp-idf Bluetooth library doesn't have much BT/RFCOMM support, so I'm starting to work on a Bluetooth implementation using Blue Kitchen's BTStack. BTStack is a third-party library that supports many hardware platforms, among them the esp32. I've got it working, but their library is rich with informational printf's that would be much better suited for ESP_LOGI() calls. The library is rather, uh, loquacious.
So, one solution would be to go through all of their code and manually change printfs to ESP_LOGI calls, but that's a lot of code to change and I'd have to redo it every time the library gets updated. Or I could try to write a little .h file with a macro redefining printf to an ESP_LOGI wrapper using some VA_ARGS magic. I'd still have to touch every module, but at least it would just be a header file include.
But the cleanest solution would be to somehow hijack the esp32 printf library function, assuming it's not needed elsewhere or by ESP_LOG itself. I'm wondering if anyone has run into this or a similar issue before, and how they solved it.
Ideas?