2022-07-20 10:56:33 +00:00
|
|
|
/**
|
|
|
|
* @file log.h
|
|
|
|
* Furi Logging system
|
|
|
|
*/
|
2021-04-30 11:20:33 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-12-14 22:39:59 +00:00
|
|
|
typedef enum {
|
|
|
|
FuriLogLevelDefault = 0,
|
|
|
|
FuriLogLevelNone = 1,
|
|
|
|
FuriLogLevelError = 2,
|
|
|
|
FuriLogLevelWarn = 3,
|
|
|
|
FuriLogLevelInfo = 4,
|
|
|
|
FuriLogLevelDebug = 5,
|
|
|
|
FuriLogLevelTrace = 6,
|
|
|
|
} FuriLogLevel;
|
2021-04-30 11:20:33 +00:00
|
|
|
|
|
|
|
#define FURI_LOG_CLR(clr) "\033[0;" clr "m"
|
|
|
|
#define FURI_LOG_CLR_RESET "\033[0m"
|
|
|
|
|
|
|
|
#define FURI_LOG_CLR_BLACK "30"
|
|
|
|
#define FURI_LOG_CLR_RED "31"
|
|
|
|
#define FURI_LOG_CLR_GREEN "32"
|
|
|
|
#define FURI_LOG_CLR_BROWN "33"
|
|
|
|
#define FURI_LOG_CLR_BLUE "34"
|
|
|
|
#define FURI_LOG_CLR_PURPLE "35"
|
|
|
|
|
|
|
|
#define FURI_LOG_CLR_E FURI_LOG_CLR(FURI_LOG_CLR_RED)
|
|
|
|
#define FURI_LOG_CLR_W FURI_LOG_CLR(FURI_LOG_CLR_BROWN)
|
|
|
|
#define FURI_LOG_CLR_I FURI_LOG_CLR(FURI_LOG_CLR_GREEN)
|
|
|
|
#define FURI_LOG_CLR_D FURI_LOG_CLR(FURI_LOG_CLR_BLUE)
|
2021-12-14 22:39:59 +00:00
|
|
|
#define FURI_LOG_CLR_T FURI_LOG_CLR(FURI_LOG_CLR_PURPLE)
|
2021-04-30 11:20:33 +00:00
|
|
|
|
2021-11-21 15:17:43 +00:00
|
|
|
typedef void (*FuriLogPuts)(const char* data);
|
2021-04-30 11:20:33 +00:00
|
|
|
typedef uint32_t (*FuriLogTimestamp)(void);
|
|
|
|
|
2022-07-20 10:56:33 +00:00
|
|
|
/** Initialize logging */
|
2021-04-30 11:20:33 +00:00
|
|
|
void furi_log_init();
|
2022-07-20 10:56:33 +00:00
|
|
|
|
2022-08-03 12:01:38 +00:00
|
|
|
/** Print log record
|
|
|
|
*
|
|
|
|
* @param level
|
|
|
|
* @param tag
|
|
|
|
* @param format
|
|
|
|
* @param ...
|
2022-07-20 10:56:33 +00:00
|
|
|
*/
|
2022-10-07 13:35:15 +00:00
|
|
|
void furi_log_print_format(FuriLogLevel level, const char* tag, const char* format, ...)
|
|
|
|
_ATTRIBUTE((__format__(__printf__, 3, 4)));
|
2022-07-20 10:56:33 +00:00
|
|
|
|
|
|
|
/** Set log level
|
|
|
|
*
|
|
|
|
* @param[in] level The level
|
|
|
|
*/
|
2021-04-30 11:20:33 +00:00
|
|
|
void furi_log_set_level(FuriLogLevel level);
|
2022-07-20 10:56:33 +00:00
|
|
|
|
|
|
|
/** Get log level
|
|
|
|
*
|
|
|
|
* @return The furi log level.
|
|
|
|
*/
|
2021-04-30 11:20:33 +00:00
|
|
|
FuriLogLevel furi_log_get_level();
|
2022-07-20 10:56:33 +00:00
|
|
|
|
|
|
|
/** Set log output callback
|
|
|
|
*
|
|
|
|
* @param[in] puts The puts callback
|
|
|
|
*/
|
2021-11-21 15:17:43 +00:00
|
|
|
void furi_log_set_puts(FuriLogPuts puts);
|
2022-07-20 10:56:33 +00:00
|
|
|
|
|
|
|
/** Set timestamp callback
|
|
|
|
*
|
|
|
|
* @param[in] timestamp The timestamp callback
|
|
|
|
*/
|
2021-04-30 11:20:33 +00:00
|
|
|
void furi_log_set_timestamp(FuriLogTimestamp timestamp);
|
|
|
|
|
2022-07-20 10:56:33 +00:00
|
|
|
/** Log methods
|
|
|
|
*
|
|
|
|
* @param tag The application tag
|
|
|
|
* @param format The format
|
|
|
|
* @param ... VA Args
|
|
|
|
*/
|
2021-12-14 22:39:59 +00:00
|
|
|
#define FURI_LOG_E(tag, format, ...) \
|
2022-08-03 12:01:38 +00:00
|
|
|
furi_log_print_format(FuriLogLevelError, tag, format, ##__VA_ARGS__)
|
|
|
|
#define FURI_LOG_W(tag, format, ...) \
|
|
|
|
furi_log_print_format(FuriLogLevelWarn, tag, format, ##__VA_ARGS__)
|
|
|
|
#define FURI_LOG_I(tag, format, ...) \
|
|
|
|
furi_log_print_format(FuriLogLevelInfo, tag, format, ##__VA_ARGS__)
|
2021-12-14 22:39:59 +00:00
|
|
|
#define FURI_LOG_D(tag, format, ...) \
|
2022-08-03 12:01:38 +00:00
|
|
|
furi_log_print_format(FuriLogLevelDebug, tag, format, ##__VA_ARGS__)
|
2021-12-14 22:39:59 +00:00
|
|
|
#define FURI_LOG_T(tag, format, ...) \
|
2022-08-03 12:01:38 +00:00
|
|
|
furi_log_print_format(FuriLogLevelTrace, tag, format, ##__VA_ARGS__)
|
2021-04-30 11:20:33 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|