Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions ar_osal/api/ar_osal_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,38 @@ void ar_log(uint32_t level, const char_t* log_tag, const char_t* file,
*/
void ar_set_log_level(uint32_t level);

/* AR_LOG_FILE_NAME: use the compiler built-in that gives only the base filename
* __FILE_NAME__ is supported by GCC >= 12 and Clang >= 9.
* Fall back to __FILE__ on older compilers.
*/
#if defined(__FILE_NAME__)
#define AR_LOG_FILE_NAME __FILE_NAME__
#else
#define AR_LOG_FILE_NAME __FILE__
#endif

#define AR_LOG_VERBOSE(log_tag, ...) \
if (ar_log_lvl & AR_VERBOSE) { \
ar_log(AR_VERBOSE, log_tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); \
ar_log(AR_VERBOSE, log_tag, AR_LOG_FILE_NAME, __FUNCTION__, __LINE__, __VA_ARGS__); \
}

#define AR_LOG_INFO(log_tag,...) \
if (ar_log_lvl & AR_INFO) { \
ar_log(AR_INFO, log_tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); \
ar_log(AR_INFO, log_tag, AR_LOG_FILE_NAME, __FUNCTION__, __LINE__, __VA_ARGS__); \
}

#define AR_LOG_DEBUG(log_tag, ...) \
if (ar_log_lvl & AR_DEBUG) { \
ar_log(AR_DEBUG, log_tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); \
ar_log(AR_DEBUG, log_tag, AR_LOG_FILE_NAME, __FUNCTION__, __LINE__, __VA_ARGS__); \
}
#define AR_LOG_ERR(log_tag, ...) \
if (ar_log_lvl & AR_ERROR) { \
ar_log(AR_ERROR, log_tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); \
ar_log(AR_ERROR, log_tag, AR_LOG_FILE_NAME, __FUNCTION__, __LINE__, __VA_ARGS__); \
}

#define AR_LOG_CRITICAL(log_tag, ...) \
if (ar_log_lvl & AR_CRITICAL) { \
ar_log(AR_CRITICAL, log_tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); \
ar_log(AR_CRITICAL, log_tag, AR_LOG_FILE_NAME, __FUNCTION__, __LINE__, __VA_ARGS__); \
}

#define AR_FATAL_PRIO (AR_CRITICAL) /**< Fatal priority debug message. */
Expand Down
Loading