mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-12-18 09:10:47 +01:00
[BREAKING] Refactor NimBLELog
* Cleanup style. * Remove NIMBLE_LOGC as it's use was limited to assertions. * Add delay after assert printf to allow time to display the message.
This commit is contained in:
parent
5afb5af81e
commit
57e583c17a
2 changed files with 32 additions and 41 deletions
|
@ -1233,7 +1233,8 @@ std::string NimBLEDevice::toString() {
|
||||||
* @param [in] line The line number where the assert occurred.
|
* @param [in] line The line number where the assert occurred.
|
||||||
*/
|
*/
|
||||||
void nimble_cpp_assert(const char* file, unsigned line) {
|
void nimble_cpp_assert(const char* file, unsigned line) {
|
||||||
NIMBLE_LOGC("", "Assertion failed at %s:%u\n", file, line);
|
console_printf("Assertion failed at %s:%u\n", file, line);
|
||||||
|
ble_npl_time_delay(10);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
# endif // CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED
|
# endif // CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED
|
||||||
|
|
|
@ -14,38 +14,31 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#ifndef MAIN_NIMBLELOG_H_
|
|
||||||
#define MAIN_NIMBLELOG_H_
|
#ifndef NIMBLE_CPP_LOG_H_
|
||||||
|
#define NIMBLE_CPP_LOG_H_
|
||||||
|
|
||||||
#include "nimconfig.h"
|
#include "nimconfig.h"
|
||||||
|
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if defined(CONFIG_BT_ENABLED)
|
||||||
|
|
||||||
#if defined(CONFIG_NIMBLE_CPP_IDF) // using esp-idf
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||||
# include "esp_log.h"
|
# include "esp_log.h"
|
||||||
# include "console/console.h"
|
# include "console/console.h"
|
||||||
# ifndef CONFIG_NIMBLE_CPP_LOG_LEVEL
|
# ifndef CONFIG_NIMBLE_CPP_LOG_LEVEL
|
||||||
# define CONFIG_NIMBLE_CPP_LOG_LEVEL 0
|
# define CONFIG_NIMBLE_CPP_LOG_LEVEL 0
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define NIMBLE_CPP_LOG_PRINT(level, tag, format, ...) do { \
|
# define NIMBLE_CPP_LOG_PRINT(level, tag, format, ...) \
|
||||||
if (CONFIG_NIMBLE_CPP_LOG_LEVEL >= level) \
|
do { \
|
||||||
ESP_LOG_LEVEL_LOCAL(level, tag, format, ##__VA_ARGS__); \
|
if (CONFIG_NIMBLE_CPP_LOG_LEVEL >= level) ESP_LOG_LEVEL_LOCAL(level, tag, format, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
# define NIMBLE_LOGD(tag, format, ...) \
|
# define NIMBLE_LOGD(tag, format, ...) NIMBLE_CPP_LOG_PRINT(ESP_LOG_DEBUG, tag, format, ##__VA_ARGS__)
|
||||||
NIMBLE_CPP_LOG_PRINT(ESP_LOG_DEBUG, tag, format, ##__VA_ARGS__)
|
# define NIMBLE_LOGI(tag, format, ...) NIMBLE_CPP_LOG_PRINT(ESP_LOG_INFO, tag, format, ##__VA_ARGS__)
|
||||||
|
# define NIMBLE_LOGW(tag, format, ...) NIMBLE_CPP_LOG_PRINT(ESP_LOG_WARN, tag, format, ##__VA_ARGS__)
|
||||||
|
# define NIMBLE_LOGE(tag, format, ...) NIMBLE_CPP_LOG_PRINT(ESP_LOG_ERROR, tag, format, ##__VA_ARGS__)
|
||||||
|
|
||||||
# define NIMBLE_LOGI(tag, format, ...) \
|
# else
|
||||||
NIMBLE_CPP_LOG_PRINT(ESP_LOG_INFO, tag, format, ##__VA_ARGS__)
|
|
||||||
|
|
||||||
# define NIMBLE_LOGW(tag, format, ...) \
|
|
||||||
NIMBLE_CPP_LOG_PRINT(ESP_LOG_WARN, tag, format, ##__VA_ARGS__)
|
|
||||||
|
|
||||||
# define NIMBLE_LOGE(tag, format, ...) \
|
|
||||||
NIMBLE_CPP_LOG_PRINT(ESP_LOG_ERROR, tag, format, ##__VA_ARGS__)
|
|
||||||
|
|
||||||
#else // using Arduino
|
|
||||||
# include "nimble/porting/nimble/include/syscfg/syscfg.h"
|
# include "nimble/porting/nimble/include/syscfg/syscfg.h"
|
||||||
# include "nimble/console/console.h"
|
# include "nimble/console/console.h"
|
||||||
# ifndef CONFIG_NIMBLE_CPP_LOG_LEVEL
|
# ifndef CONFIG_NIMBLE_CPP_LOG_LEVEL
|
||||||
|
@ -81,8 +74,5 @@
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# endif /* CONFIG_NIMBLE_CPP_IDF */
|
# endif /* CONFIG_NIMBLE_CPP_IDF */
|
||||||
|
|
||||||
#define NIMBLE_LOGC( tag, format, ... ) console_printf("CRIT %s: " format "\n", tag, ##__VA_ARGS__)
|
|
||||||
|
|
||||||
#endif /* CONFIG_BT_ENABLED */
|
#endif /* CONFIG_BT_ENABLED */
|
||||||
#endif /* MAIN_NIMBLELOG_H_ */
|
#endif /* NIMBLE_CPP_LOG_H_ */
|
||||||
|
|
Loading…
Reference in a new issue