Flipper Zero Firmware
Loading...
Searching...
No Matches
log.h File Reference

Furi Logging system. More...

#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  FuriLogHandler
 

Macros

#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)
 
#define _FURI_LOG_CLR_T   _FURI_LOG_CLR(_FURI_LOG_CLR_PURPLE)
 
#define FURI_LOG_E(tag, format, ...)    furi_log_print_format(FuriLogLevelError, tag, format, ##__VA_ARGS__)
 Log methods.
 
#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__)
 
#define FURI_LOG_D(tag, format, ...)    furi_log_print_format(FuriLogLevelDebug, tag, format, ##__VA_ARGS__)
 
#define FURI_LOG_T(tag, format, ...)    furi_log_print_format(FuriLogLevelTrace, tag, format, ##__VA_ARGS__)
 
#define FURI_LOG_RAW_E(format, ...)    furi_log_print_raw_format(FuriLogLevelError, format, ##__VA_ARGS__)
 Log methods.
 
#define FURI_LOG_RAW_W(format, ...)    furi_log_print_raw_format(FuriLogLevelWarn, format, ##__VA_ARGS__)
 
#define FURI_LOG_RAW_I(format, ...)    furi_log_print_raw_format(FuriLogLevelInfo, format, ##__VA_ARGS__)
 
#define FURI_LOG_RAW_D(format, ...)    furi_log_print_raw_format(FuriLogLevelDebug, format, ##__VA_ARGS__)
 
#define FURI_LOG_RAW_T(format, ...)    furi_log_print_raw_format(FuriLogLevelTrace, format, ##__VA_ARGS__)
 

Typedefs

typedef void(* FuriLogHandlerCallback) (const uint8_t *data, size_t size, void *context)
 

Enumerations

enum  FuriLogLevel {
  FuriLogLevelDefault = 0 , FuriLogLevelNone = 1 , FuriLogLevelError = 2 , FuriLogLevelWarn = 3 ,
  FuriLogLevelInfo = 4 , FuriLogLevelDebug = 5 , FuriLogLevelTrace = 6
}
 

Functions

void furi_log_init (void)
 Initialize logging.
 
bool furi_log_add_handler (FuriLogHandler handler)
 Add log TX callback.
 
bool furi_log_remove_handler (FuriLogHandler handler)
 Remove log TX callback.
 
void furi_log_tx (const uint8_t *data, size_t size)
 Transmit data through log IO callbacks.
 
void furi_log_puts (const char *data)
 Transmit data through log IO callbacks.
 
void furi_log_print_format (FuriLogLevel level, const char *tag, const char *format,...) _ATTRIBUTE((__format__(__printf__
 Print log record.
 
void void furi_log_print_raw_format (FuriLogLevel level, const char *format,...) _ATTRIBUTE((__format__(__printf__
 Print log record.
 
void void void furi_log_set_level (FuriLogLevel level)
 Set log level.
 
FuriLogLevel furi_log_get_level (void)
 Get log level.
 
bool furi_log_level_to_string (FuriLogLevel level, const char **str)
 Log level to string.
 
bool furi_log_level_from_string (const char *str, FuriLogLevel *level)
 Log level from string.
 

Detailed Description

Furi Logging system.

Macro Definition Documentation

◆ FURI_LOG_E

#define FURI_LOG_E ( tag,
format,
... )    furi_log_print_format(FuriLogLevelError, tag, format, ##__VA_ARGS__)

Log methods.

Parameters
tagThe application tag
formatThe format
...VA Args

◆ FURI_LOG_RAW_E

#define FURI_LOG_RAW_E ( format,
... )    furi_log_print_raw_format(FuriLogLevelError, format, ##__VA_ARGS__)

Log methods.

Parameters
formatThe raw format
...VA Args

Function Documentation

◆ furi_log_add_handler()

bool furi_log_add_handler ( FuriLogHandler handler)

Add log TX callback.

Parameters
[in]handlerThe callback and its context
Returns
true on success, false otherwise

◆ furi_log_get_level()

FuriLogLevel furi_log_get_level ( void )

Get log level.

Returns
The furi log level.

◆ furi_log_level_from_string()

bool furi_log_level_from_string ( const char * str,
FuriLogLevel * level )

Log level from string.

Parameters
[in]strThe string
[out]levelThe level
Returns
True if success, False otherwise

◆ furi_log_level_to_string()

bool furi_log_level_to_string ( FuriLogLevel level,
const char ** str )

Log level to string.

Parameters
[in]levelThe level
[out]strString representation of the level
Returns
True if success, False otherwise

◆ furi_log_print_format()

void furi_log_print_format ( FuriLogLevel level,
const char * tag,
const char * format,
... )

Print log record.

Parameters
level
tag
format
...

◆ furi_log_print_raw_format()

void void furi_log_print_raw_format ( FuriLogLevel level,
const char * format,
... )

Print log record.

Parameters
level
format
...

◆ furi_log_puts()

void furi_log_puts ( const char * data)

Transmit data through log IO callbacks.

Parameters
[in]dataThe data, null-terminated C-string

◆ furi_log_remove_handler()

bool furi_log_remove_handler ( FuriLogHandler handler)

Remove log TX callback.

Parameters
[in]handlerThe callback and its context
Returns
true on success, false otherwise

◆ furi_log_set_level()

void void void furi_log_set_level ( FuriLogLevel level)

Set log level.

Parameters
[in]levelThe level

◆ furi_log_tx()

void furi_log_tx ( const uint8_t * data,
size_t size )

Transmit data through log IO callbacks.

Parameters
[in]dataThe data
[in]sizeThe size