hekate/bdk/libs/lvgl/lv_misc/lv_log.c
CTCaer 185526d134 Introducing Bootloader Development Kit (BDK)
BDK will allow developers to use the full collection of drivers,
with limited editing, if any, for making payloads for Nintendo Switch.

Using a single source for everything will also help decoupling
Switch specific code and easily port it to other Tegra X1/X1+ platforms.
And maybe even to lower targets.

Everything is now centrilized into bdk folder.
Every module or project can utilize it by simply including it.

This is just the start and it will continue to improve.
2020-06-14 15:25:21 +03:00

82 lines
2 KiB
C

/**
* @file lv_log.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_log.h"
#if USE_LV_LOG
#if LV_LOG_PRINTF
#include <string.h>
#include "../../../mem/heap.h"
#include "../../../soc/uart.h"
#include "../../../utils/sprintf.h"
#endif
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
static void (*print_cb)(lv_log_level_t, const char *, uint32_t, const char *);
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* 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)`
*/
void lv_log_register_print(void f(lv_log_level_t, const char *, uint32_t, const char *))
{
print_cb = f;
}
/**
* Add a log
* @param level the level of log. (From `lv_log_level_t` enum)
* @param file name of the file when the log added
* @param line line number in the source code where the log added
* @param dsc description of the log
*/
void lv_log_add(lv_log_level_t level, const char * file, int line, const char * dsc)
{
if(level >= _LV_LOG_LEVEL_NUM) return; /*Invalid level*/
if(level >= LV_LOG_LEVEL) {
#if LV_LOG_PRINTF
static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error"};
char *log = (char *)malloc(0x1000);
s_printf(log, "%s: %s \t(%s #%d)\r\n", lvl_prefix[level], dsc, file, line);
uart_send(UART_B, (u8 *)log, strlen(log) + 1);
//gfx_printf("%s: %s \t(%s #%d)\n", lvl_prefix[level], dsc, file, line);
#else
if(print_cb) print_cb(level, file, line, dsc);
#endif
}
}
/**********************
* STATIC FUNCTIONS
**********************/
#endif /*USE_LV_LOG*/