-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,45 @@ | ||
#pragma once | ||
|
||
#if defined (ASHA_LOG_ERROR) || defined (ASHA_LOG_INFO) || defined (ASHA_LOG_AUDIO) | ||
#include <stdio.h> | ||
#include "pico/time.h" | ||
#ifdef ASHA_HCI_DUMP | ||
#include "hci_dump_embedded_stdout.h" | ||
#include "btstack_debug.h" | ||
#endif | ||
#endif | ||
#include "hci_dump_embedded_stdout.h" | ||
#include "btstack_debug.h" | ||
#include "runtime_settings.hpp" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
namespace asha | ||
{ | ||
|
||
#ifdef ASHA_HCI_DUMP | ||
#if defined (ASHA_LOG_ERROR) | ||
#define LOG_ERROR(fmt, ...) log_error(fmt, ##__VA_ARGS__) | ||
#define LOG_INFO(fmt, ...) | ||
#define LOG_SCAN(fmt, ...) | ||
#define LOG_AUDIO(fmt, ...) | ||
#elif defined (ASHA_LOG_INFO) | ||
#define LOG_ERROR(fmt, ...) log_info(fmt, ##__VA_ARGS__) | ||
#define LOG_INFO(fmt, ...) log_info(fmt, ##__VA_ARGS__) | ||
#define LOG_SCAN(fmt, ...) | ||
#define LOG_AUDIO(fmt, ...) | ||
#elif defined (ASHA_LOG_SCAN) | ||
#define LOG_ERROR(fmt, ...) log_info(fmt, ##__VA_ARGS__) | ||
#define LOG_INFO(fmt, ...) log_info(fmt, ##__VA_ARGS__) | ||
#define LOG_SCAN(fmt, ...) log_info(fmt, ##__VA_ARGS__) | ||
#define LOG_AUDIO(fmt, ...) | ||
#elif defined (ASHA_LOG_AUDIO) | ||
#define LOG_ERROR(fmt, ...) log_info(fmt, ##__VA_ARGS__) | ||
#define LOG_INFO(fmt, ...) log_info(fmt, ##__VA_ARGS__) | ||
#define LOG_SCAN(fmt, ...) log_info(fmt, ##__VA_ARGS__) | ||
#define LOG_AUDIO(fmt, ...) log_info(fmt, ##__VA_ARGS__) | ||
#else | ||
#define LOG_ERROR(fmt, ...) | ||
#define LOG_INFO(fmt, ...) | ||
#define LOG_SCAN(fmt, ...) | ||
#define LOG_AUDIO(fmt, ...) | ||
#endif | ||
#else | ||
#if defined (ASHA_LOG_ERROR) | ||
#define LOG_ERROR(fmt, ...) printf("[ASHA ERROR : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__) | ||
#define LOG_INFO(fmt, ...) | ||
#define LOG_SCAN(fmt, ...) | ||
#define LOG_AUDIO(fmt, ...) | ||
#elif defined (ASHA_LOG_INFO) | ||
#define LOG_ERROR(fmt, ...) printf("[ASHA ERROR : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__) | ||
#define LOG_INFO(fmt, ...) printf("[ASHA INFO : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__) | ||
#define LOG_SCAN(fmt, ...) | ||
#define LOG_AUDIO(fmt, ...) | ||
#elif defined (ASHA_LOG_SCAN) | ||
#define LOG_ERROR(fmt, ...) printf("[ASHA ERROR : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__) | ||
#define LOG_INFO(fmt, ...) printf("[ASHA INFO : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__) | ||
#define LOG_SCAN(fmt, ...) printf("[ASHA SCAN : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__) | ||
#define LOG_AUDIO(fmt, ...) | ||
#elif defined (ASHA_LOG_AUDIO) | ||
#define LOG_ERROR(fmt, ...) printf("[ASHA ERROR : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__) | ||
#define LOG_INFO(fmt, ...) printf("[ASHA INFO : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__) | ||
#define LOG_SCAN(fmt, ...) printf("[ASHA SCAN : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__) | ||
#define LOG_AUDIO(fmt, ...) printf("[ASHA AUDIO : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__) | ||
#else | ||
#define LOG_ERROR(fmt, ...) | ||
#define LOG_INFO(fmt, ...) | ||
#define LOG_SCAN(fmt, ...) | ||
#define LOG_AUDIO(fmt, ...) | ||
#endif | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
#define asha_log(level, fmt, ...) if (runtime_settings.hci_dump_enabled) { \ | ||
switch ((level)) { \ | ||
case LogLevel::Error: \ | ||
log_error(fmt, ##__VA_ARGS__); \ | ||
break; \ | ||
case LogLevel::Info: \ | ||
case LogLevel::Scan: \ | ||
case LogLevel::Audio: \ | ||
log_info(fmt, ##__VA_ARGS__); \ | ||
break; \ | ||
} \ | ||
} else { \ | ||
switch ((level)) { \ | ||
case LogLevel::Error: \ | ||
printf("[ASHA ERROR : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__); \ | ||
break; \ | ||
case LogLevel::Info: \ | ||
printf("[ASHA INFO : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__); \ | ||
break; \ | ||
case LogLevel::Scan: \ | ||
printf("[ASHA SCAN : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__); \ | ||
break; \ | ||
case LogLevel::Audio: \ | ||
printf("[ASHA AUDIO : %u ms] " fmt "\n", to_ms_since_boot(get_absolute_time()), ##__VA_ARGS__); \ | ||
break; \ | ||
} \ | ||
} | ||
#endif | ||
|
||
#define LOG_ERROR(fmt, ...) if (runtime_settings.log_level >= LogLevel::Error) asha_log(LogLevel::Error, fmt, ##__VA_ARGS__) | ||
#define LOG_INFO(fmt, ...) if (runtime_settings.log_level >= LogLevel::Info) asha_log(LogLevel::Info, fmt, ##__VA_ARGS__) | ||
#define LOG_SCAN(fmt, ...) if (runtime_settings.log_level >= LogLevel::Scan) asha_log(LogLevel::Scan, fmt, ##__VA_ARGS__) | ||
#define LOG_AUDIO(fmt, ...) if (runtime_settings.log_level >= LogLevel::Audio) asha_log(LogLevel::Audio, fmt, ##__VA_ARGS__) | ||
|
||
} // namespace asha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters