diff --git a/src/lv_misc/lv_log.c b/src/lv_misc/lv_log.c index 67680b855..2d12da4e1 100644 --- a/src/lv_misc/lv_log.c +++ b/src/lv_misc/lv_log.c @@ -27,7 +27,7 @@ /********************** * STATIC VARIABLES **********************/ -static void (*print_cb)(lv_log_level_t, const char *, uint32_t, const char *); +static lv_log_print_g_cb_t custom_print_cb; /********************** * MACROS @@ -38,14 +38,14 @@ static void (*print_cb)(lv_log_level_t, const char *, uint32_t, const char *); **********************/ /** - * Register custom print (or anything else) function to call when log is added - * @param f a function pointer: - * `void my_print (lv_log_level_t level, const char * file, uint32_t line, const char * - * dsc)` + * Register custom print/write function to call when a log is added. + * It can format its "File path", "Line number" and "Description" as required + * and send the formatted log message to a consol or serial port. + * @param print_cb a function pointer to print a log */ -void lv_log_register_print(void f(lv_log_level_t, const char *, uint32_t, const char *)) +void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb) { - print_cb = f; + custom_print_cb = print_cb; } /** @@ -65,7 +65,7 @@ void lv_log_add(lv_log_level_t level, const char * file, int line, const char * static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error"}; printf("%s: %s \t(%s #%d)\n", lvl_prefix[level], dsc, file, line); #else - if(print_cb) print_cb(level, file, line, dsc); + if(custom_print_cb) custom_print_cb(level, file, line, dsc); #endif } } diff --git a/src/lv_misc/lv_log.h b/src/lv_misc/lv_log.h index 26557cae8..5292b746d 100644 --- a/src/lv_misc/lv_log.h +++ b/src/lv_misc/lv_log.h @@ -39,17 +39,22 @@ typedef int8_t lv_log_level_t; * TYPEDEFS **********************/ +/** + * Log print function. Receives "File path", "Line number" and "Description". + */ +typedef void (*lv_log_print_g_cb_t) (const char *, uint32_t, const char *); + /********************** * GLOBAL PROTOTYPES **********************/ /** - * Register custom print (or anything else) function to call when log is added - * @param f a function pointer: - * `void my_print (lv_log_level_t level, const char * file, uint32_t line, const char * - * dsc)` + * Register custom print/write function to call when a log is added. + * It can format its "File path", "Line number" and "Description" as required + * and send the formatted log message to a consol or serial port. + * @param print_cb a function pointer to print a log */ -void lv_log_register_print(void f(lv_log_level_t, const char *, uint32_t, const char *)); +void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb); /** * Add a log