acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

lv_log.h (4437B)

      1 /**
      2  * @file lv_log.h
      3  *
      4  */
      5 
      6 #ifndef LV_LOG_H
      7 #define LV_LOG_H
      8 
      9 #ifdef __cplusplus
     10 extern "C" {
     11 #endif
     12 
     13 /*********************
     14  *      INCLUDES
     15  *********************/
     16 #include "../lv_conf_internal.h"
     17 #include <stdint.h>
     18 
     19 #include "lv_types.h"
     20 
     21 /*********************
     22  *      DEFINES
     23  *********************/
     24 
     25 /*Possible log level. For compatibility declare it independently from `LV_USE_LOG`*/
     26 
     27 #define LV_LOG_LEVEL_TRACE 0 /**< A lot of logs to give detailed information*/
     28 #define LV_LOG_LEVEL_INFO  1 /**< Log important events*/
     29 #define LV_LOG_LEVEL_WARN  2 /**< Log if something unwanted happened but didn't caused problem*/
     30 #define LV_LOG_LEVEL_ERROR 3 /**< Only critical issue, when the system may fail*/
     31 #define LV_LOG_LEVEL_USER  4 /**< Custom logs from the user*/
     32 #define LV_LOG_LEVEL_NONE  5 /**< Do not log anything*/
     33 #define _LV_LOG_LEVEL_NUM  6 /**< Number of log levels*/
     34 
     35 LV_EXPORT_CONST_INT(LV_LOG_LEVEL_TRACE);
     36 LV_EXPORT_CONST_INT(LV_LOG_LEVEL_INFO);
     37 LV_EXPORT_CONST_INT(LV_LOG_LEVEL_WARN);
     38 LV_EXPORT_CONST_INT(LV_LOG_LEVEL_ERROR);
     39 LV_EXPORT_CONST_INT(LV_LOG_LEVEL_USER);
     40 LV_EXPORT_CONST_INT(LV_LOG_LEVEL_NONE);
     41 
     42 typedef int8_t lv_log_level_t;
     43 
     44 #if LV_USE_LOG
     45 /**********************
     46  *      TYPEDEFS
     47  **********************/
     48 
     49 /**
     50  * Log print function. Receives a string buffer to print".
     51  */
     52 typedef void (*lv_log_print_g_cb_t)(const char * buf);
     53 
     54 /**********************
     55  * GLOBAL PROTOTYPES
     56  **********************/
     57 
     58 /**
     59  * Register custom print/write function to call when a log is added.
     60  * It can format its "File path", "Line number" and "Description" as required
     61  * and send the formatted log message to a console or serial port.
     62  * @param           print_cb a function pointer to print a log
     63  */
     64 void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb);
     65 
     66 /**
     67  * Print a log message via `printf` if enabled with `LV_LOG_PRINTF` in `lv_conf.h`
     68  * and/or a print callback if registered with `lv_log_register_print_cb`
     69  * @param format    printf-like format string
     70  * @param ...       parameters for `format`
     71  */
     72 void lv_log(const char * format, ...) LV_FORMAT_ATTRIBUTE(1, 2);
     73 
     74 /**
     75  * Add a log
     76  * @param level     the level of log. (From `lv_log_level_t` enum)
     77  * @param file      name of the file when the log added
     78  * @param line      line number in the source code where the log added
     79  * @param func      name of the function when the log added
     80  * @param format    printf-like format string
     81  * @param ...       parameters for `format`
     82  */
     83 void _lv_log_add(lv_log_level_t level, const char * file, int line,
     84                  const char * func, const char * format, ...) LV_FORMAT_ATTRIBUTE(5, 6);
     85 
     86 /**********************
     87  *      MACROS
     88  **********************/
     89 #ifndef LV_LOG_TRACE
     90 #  if LV_LOG_LEVEL <= LV_LOG_LEVEL_TRACE
     91 #    define LV_LOG_TRACE(...) _lv_log_add(LV_LOG_LEVEL_TRACE, __FILE__, __LINE__, __func__, __VA_ARGS__)
     92 #  else
     93 #    define LV_LOG_TRACE(...) do {}while(0)
     94 #  endif
     95 #endif
     96 
     97 #ifndef LV_LOG_INFO
     98 #  if LV_LOG_LEVEL <= LV_LOG_LEVEL_INFO
     99 #    define LV_LOG_INFO(...) _lv_log_add(LV_LOG_LEVEL_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__)
    100 #  else
    101 #    define LV_LOG_INFO(...) do {}while(0)
    102 #  endif
    103 #endif
    104 
    105 #ifndef LV_LOG_WARN
    106 #  if LV_LOG_LEVEL <= LV_LOG_LEVEL_WARN
    107 #    define LV_LOG_WARN(...) _lv_log_add(LV_LOG_LEVEL_WARN, __FILE__, __LINE__, __func__, __VA_ARGS__)
    108 #  else
    109 #    define LV_LOG_WARN(...) do {}while(0)
    110 #  endif
    111 #endif
    112 
    113 #ifndef LV_LOG_ERROR
    114 #  if LV_LOG_LEVEL <= LV_LOG_LEVEL_ERROR
    115 #    define LV_LOG_ERROR(...) _lv_log_add(LV_LOG_LEVEL_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__)
    116 #  else
    117 #    define LV_LOG_ERROR(...) do {}while(0)
    118 #  endif
    119 #endif
    120 
    121 #ifndef LV_LOG_USER
    122 #  if LV_LOG_LEVEL <= LV_LOG_LEVEL_USER
    123 #    define LV_LOG_USER(...) _lv_log_add(LV_LOG_LEVEL_USER, __FILE__, __LINE__, __func__, __VA_ARGS__)
    124 #  else
    125 #    define LV_LOG_USER(...) do {}while(0)
    126 #  endif
    127 #endif
    128 
    129 #ifndef LV_LOG
    130 #  if LV_LOG_LEVEL < LV_LOG_LEVEL_NONE
    131 #    define LV_LOG(...) lv_log(__VA_ARGS__)
    132 #  else
    133 #    define LV_LOG(...) do {} while(0)
    134 #  endif
    135 #endif
    136 
    137 #else /*LV_USE_LOG*/
    138 
    139 /*Do nothing if `LV_USE_LOG 0`*/
    140 #define _lv_log_add(level, file, line, ...)
    141 #define LV_LOG_TRACE(...) do {}while(0)
    142 #define LV_LOG_INFO(...) do {}while(0)
    143 #define LV_LOG_WARN(...) do {}while(0)
    144 #define LV_LOG_ERROR(...) do {}while(0)
    145 #define LV_LOG_USER(...) do {}while(0)
    146 #define LV_LOG(...) do {}while(0)
    147 
    148 #endif /*LV_USE_LOG*/
    149 
    150 #ifdef __cplusplus
    151 } /*extern "C"*/
    152 #endif
    153 
    154 #endif /*LV_LOG_H*/