Forward log and log level to custom bh_log callback (#3070)
Follow-up on #2907. The log level is needed in the host embedder to better integrate with the embedder's logger. Allow the developer to customize his bh_log callback with `cmake -DWAMR_BH_LOG=<log_callback>`, and update sample/basic to show the usage.
This commit is contained in:
@ -17,6 +17,7 @@ bh_log_set_verbose_level(uint32 level)
|
||||
log_verbose_level = level;
|
||||
}
|
||||
|
||||
#ifndef BH_LOG
|
||||
void
|
||||
bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...)
|
||||
{
|
||||
@ -56,6 +57,7 @@ bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...)
|
||||
|
||||
os_printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint32 last_time_ms = 0;
|
||||
static uint32 total_time_ms = 0;
|
||||
|
||||
@ -38,8 +38,14 @@ typedef enum {
|
||||
void
|
||||
bh_log_set_verbose_level(uint32 level);
|
||||
|
||||
#ifndef BH_LOG
|
||||
void
|
||||
bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...);
|
||||
#else
|
||||
void
|
||||
BH_LOG(uint32 log_level, const char *file, int line, const char *fmt, ...);
|
||||
#define bh_log BH_LOG
|
||||
#endif
|
||||
|
||||
#ifdef BH_PLATFORM_NUTTX
|
||||
|
||||
|
||||
Reference in New Issue
Block a user