# lv_log.h (/api/public/logging/lv_log_h)



<ApiSummary functions="3" typedefs="2" macros="10" />

Functions [#functions]

<ApiMember kind="function" name="lv_log_register_print_cb" file="public/logging/lv_log.h" line="63" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L63">
  lv_log_register_print_cb [#lv_log_register_print_cb]

  Register custom print/write function to call when a log is added. It can format its "File path", "Line number" and "Description" as required and send the formatted log message to a console or serial port.

  ```c title=" " lineNumbers=1
  void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name       | Type                                   | Description                       |
  | ---------- | -------------------------------------- | --------------------------------- |
  | `print_cb` | <ApiLink name="lv_log_print_g_cb_t" /> | a function pointer to print a log |
</ApiMember>

<ApiMember kind="function" name="lv_log" file="public/logging/lv_log.h" line="71" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L71">
  lv_log [#lv_log]

  Print a log message via `printf` if enabled with `LV_LOG_PRINTF` in `lv_conf.h` and/or a print callback if registered with `lv_log_register_print_cb`

  ```c title=" " lineNumbers=1
  void lv_log(const char *format,...)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type           | Description               |
  | -------- | -------------- | ------------------------- |
  | `format` | `const char *` | printf-like format string |
  | `...`    |                |                           |
</ApiMember>

<ApiMember kind="function" name="lv_log_add" file="public/logging/lv_log.h" line="82" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L82">
  lv_log_add [#lv_log_add]

  Add a log

  ```c title=" " lineNumbers=1
  void lv_log_add(lv_log_level_t level, const char *file, int line, const char *func, const char *format,...)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                              | Description                                        |
  | -------- | --------------------------------- | -------------------------------------------------- |
  | `level`  | <ApiLink name="lv_log_level_t" /> | the level of log. (From `lv_log_level_t` enum)     |
  | `file`   | `const char *`                    | name of the file when the log added                |
  | `line`   | `int`                             | line number in the source code where the log added |
  | `func`   | `const char *`                    | name of the function when the log added            |
  | `format` | `const char *`                    | printf-like format string                          |
  | `...`    |                                   |                                                    |
</ApiMember>

Typedefs [#typedefs]

<ApiMember kind="typedef" name="lv_log_level_t" file="public/logging/lv_log.h" line="32" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L32">
  lv_log_level_t [#lv_log_level_t]

  ```c title=" " lineNumbers=1
  typedef int8_t lv_log_level_t
  ```
</ApiMember>

<TypeUsedBy name="lv_log_level_t" count="1">
  * `lv_log_add` — param `level`
</TypeUsedBy>

<ApiMember kind="typedef" name="lv_log_print_g_cb_t" file="public/logging/lv_log.h" line="51" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L51">
  lv_log_print_g_cb_t [#lv_log_print_g_cb_t]

  ```c title=" " lineNumbers=1
  typedef void(* lv_log_print_g_cb_t) (lv_log_level_t level, const char *buf)
  ```

  Log print function. Receives a string buffer to print".
</ApiMember>

<TypeUsedBy name="lv_log_print_g_cb_t" count="1">
  * `lv_log_register_print_cb` — param `print_cb`
</TypeUsedBy>

Macros [#macros]

<ApiMember kind="macro" name="LV_LOG_FILE" file="public/logging/lv_log.h" line="37" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L37">
  LV_LOG_FILE [#lv_log_file]

  ```c title=" " lineNumbers=1
  #define LV_LOG_FILE __FILE__
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_LOG_LINE" file="public/logging/lv_log.h" line="38" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L38">
  LV_LOG_LINE [#lv_log_line]

  ```c title=" " lineNumbers=1
  #define LV_LOG_LINE __LINE__
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_LOG_TRACE" file="public/logging/lv_log.h" line="92" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L92">
  LV_LOG_TRACE [#lv_log_trace]

  ```c title=" " lineNumbers=1
  #define LV_LOG_TRACE(...) \
      do {}while(0)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_LOG_INFO" file="public/logging/lv_log.h" line="100" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L100">
  LV_LOG_INFO [#lv_log_info]

  ```c title=" " lineNumbers=1
  #define LV_LOG_INFO(...) \
      do {}while(0)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_LOG_WARN" file="public/logging/lv_log.h" line="106" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L106">
  LV_LOG_WARN [#lv_log_warn]

  ```c title=" " lineNumbers=1
  #define LV_LOG_WARN(...) \
      lv_log_add(LV_LOG_LEVEL_WARN, LV_LOG_FILE, LV_LOG_LINE, __func__, __VA_ARGS__)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_LOG_WARN_ONCE" file="public/logging/lv_log.h" line="115" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L115">
  LV_LOG_WARN_ONCE [#lv_log_warn_once]

  ```c title=" " lineNumbers=1
  #define LV_LOG_WARN_ONCE(...) \
      do { \
              static int warned = 0; \
              if(!warned) { \
                  warned = 1; \
                  lv_log_add(LV_LOG_LEVEL_WARN, LV_LOG_FILE, LV_LOG_LINE, __func__, __VA_ARGS__); \
              } \
          } while(0)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_LOG_DEPRECATED" file="public/logging/lv_log.h" line="128" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L128">
  LV_LOG_DEPRECATED [#lv_log_deprecated]

  ```c title=" " lineNumbers=1
  #define LV_LOG_DEPRECATED(msg) \
      LV_LOG_WARN_ONCE("Deprecated: " msg)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_LOG_ERROR" file="public/logging/lv_log.h" line="133" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L133">
  LV_LOG_ERROR [#lv_log_error]

  ```c title=" " lineNumbers=1
  #define LV_LOG_ERROR(...) \
      lv_log_add(LV_LOG_LEVEL_ERROR, LV_LOG_FILE, LV_LOG_LINE, __func__, __VA_ARGS__)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_LOG_USER" file="public/logging/lv_log.h" line="141" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L141">
  LV_LOG_USER [#lv_log_user]

  ```c title=" " lineNumbers=1
  #define LV_LOG_USER(...) \
      lv_log_add(LV_LOG_LEVEL_USER, LV_LOG_FILE, LV_LOG_LINE, __func__, __VA_ARGS__)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_LOG" file="public/logging/lv_log.h" line="149" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/logging/lv_log.h#L149">
  LV_LOG [#lv_log-1]

  ```c title=" " lineNumbers=1
  #define LV_LOG(...) \
      lv_log(__VA_ARGS__)
  ```
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_conf_internal.h&#x22;, &#x22;lv_types.h&#x22;]" includedBy="[&#x22;lv_assert.h&#x22;, &#x22;lv_check_arg.h&#x22;, &#x22;lv_check_obj.h&#x22;, &#x22;lvgl.h&#x22;]" />
