buffybox/shared/log.h

49 lines
983 B
C
Raw Permalink Normal View History

2021-09-23 21:05:36 +02:00
/**
* Copyright 2021 Johannes Marbach
* SPDX-License-Identifier: GPL-3.0-or-later
2021-09-23 21:05:36 +02:00
*/
2024-01-12 10:00:05 +01:00
2024-03-30 20:52:01 +01:00
#ifndef BBX_LOG_H
#define BBX_LOG_H
2021-09-23 21:05:36 +02:00
2024-01-25 09:59:45 +00:00
#include "lvgl/lvgl.h"
2021-09-23 21:05:36 +02:00
/**
* Log levels
*/
typedef enum {
/* Errors only */
2024-03-30 20:52:01 +01:00
BBX_LOG_LEVEL_ERROR = 0,
/* Warnings and errors */
2024-03-30 20:52:01 +01:00
BBX_LOG_LEVEL_WARNING = 1,
2021-09-23 21:05:36 +02:00
/* Include non-errors in log */
2024-03-30 20:52:01 +01:00
BBX_LOG_LEVEL_VERBOSE = 2
} bbx_log_level;
2021-09-23 21:05:36 +02:00
/**
* Set the log level.
*
* @param level new log level value
*/
2024-03-30 20:52:01 +01:00
void bbx_log_set_level(bbx_log_level level);
2021-09-23 21:05:36 +02:00
/**
2021-09-25 14:34:54 +02:00
* Log a message. A newline character is appended unless the message ends in one.
2021-09-23 21:05:36 +02:00
*
* @param level log level of the message
* @param format message format string
* @param ... parameters to fill into the format string
*/
2024-03-30 20:52:01 +01:00
void bbx_log(bbx_log_level level, const char *format, ...);
2021-09-23 21:05:36 +02:00
/**
* Handle an LVGL log message.
2024-01-25 09:59:45 +00:00
*
* @param level LVGL log level
2021-09-23 21:05:36 +02:00
* @param msg message to print
*/
2024-03-30 20:52:01 +01:00
void bbx_log_print_cb(lv_log_level_t level, const char *msg);
2021-09-23 21:05:36 +02:00
2024-03-30 20:52:01 +01:00
#endif /* BBX_LOG_H */