1.. _logging:
2
3=======
4Logging
5=======
6
7LVGL has a built-in *Log* module to inform the user about what is
8happening in the library.
9
10
11Log Level
12*********
13
14To enable logging, set :c:macro:`LV_USE_LOG` in ``lv_conf.h`` and set
15:c:macro:`LV_LOG_LEVEL` to one of the following values:
16
17- :c:macro:`LV_LOG_LEVEL_TRACE`: A lot of logs to give detailed information
18- :c:macro:`LV_LOG_LEVEL_INFO`: Log important events
19- :c:macro:`LV_LOG_LEVEL_WARN`: Log if something unwanted happened but didn't cause a problem
20- :c:macro:`LV_LOG_LEVEL_ERROR`: Only critical issues, where the system may fail
21- :c:macro:`LV_LOG_LEVEL_USER`: Only user messages
22- :c:macro:`LV_LOG_LEVEL_NONE`: Do not log anything
23
24The events which have a higher level than the set log level will be logged
25as well. E.g. if you :c:macro:`LV_LOG_LEVEL_WARN`, errors will be also logged.
26
27
28Printing Logs
29*************
30
31Logging with printf
32-------------------
33
34If your system supports ``printf``, you just need to enable
35:c:macro:`LV_LOG_PRINTF` in ``lv_conf.h`` to send the logs with ``printf``.
36
37Custom log function
38-------------------
39
40If you can't use ``printf`` or want to use a custom function to log, you
41can register a "logger" callback with :cpp:func:`lv_log_register_print_cb`.
42
43For example:
44
45.. code-block:: c
46
47   void my_log_cb(lv_log_level_t level, const char * buf)
48   {
49     serial_send(buf, strlen(buf));
50   }
51
52   ...
53
54
55   lv_log_register_print_cb(my_log_cb);
56
57
58Add Logs
59********
60
61You can also use the log module via the
62``LV_LOG_TRACE/INFO/WARN/ERROR/USER(text)`` or ``LV_LOG(text)``
63functions. Here:
64
65-  ``LV_LOG_TRACE/INFO/WARN/ERROR/USER(text)`` append the following information to your ``text``
66-  Log Level
67-  \__FILE\_\_
68-  \__LINE\_\_
69-  \__func\_\_
70-  ``LV_LOG(text)`` is similar to ``LV_LOG_USER`` but has no extra information attached.
71
72API
73***
74