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