mikroSDK Reference Manual
lv_log.h
Go to the documentation of this file.
1
6#ifndef LV_LOG_H
7#define LV_LOG_H
8
9#ifdef __cplusplus
10extern "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
28#define LV_LOG_LEVEL_INFO 1
29#define LV_LOG_LEVEL_WARN 2
30#define LV_LOG_LEVEL_ERROR 3
31#define LV_LOG_LEVEL_USER 4
32#define LV_LOG_LEVEL_NONE 5
33#define _LV_LOG_LEVEL_NUM 6
35LV_EXPORT_CONST_INT(LV_LOG_LEVEL_TRACE);
36LV_EXPORT_CONST_INT(LV_LOG_LEVEL_INFO);
37LV_EXPORT_CONST_INT(LV_LOG_LEVEL_WARN);
38LV_EXPORT_CONST_INT(LV_LOG_LEVEL_ERROR);
39LV_EXPORT_CONST_INT(LV_LOG_LEVEL_USER);
40LV_EXPORT_CONST_INT(LV_LOG_LEVEL_NONE);
41
42typedef int8_t lv_log_level_t;
43
44#if LV_USE_LOG
45/**********************
46 * TYPEDEFS
47 **********************/
48
52typedef void (*lv_log_print_g_cb_t)(const char * buf);
53
54/**********************
55 * GLOBAL PROTOTYPES
56 **********************/
57
64void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb);
65
72void lv_log(const char * format, ...) LV_FORMAT_ATTRIBUTE(1, 2);
73
83void _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*/
#define LV_LOG_LEVEL_ERROR
Definition lv_log.h:30
#define LV_LOG_LEVEL_INFO
Definition lv_log.h:28
#define LV_LOG_LEVEL_TRACE
Definition lv_log.h:27
#define LV_LOG_LEVEL_USER
Definition lv_log.h:31
#define LV_LOG_LEVEL_NONE
Definition lv_log.h:32
#define LV_LOG_LEVEL_WARN
Definition lv_log.h:29