hsw-nbt 1.2.0
OPTIGA Authenticate NBT Host Library for C
Data Structures | Macros | Typedefs | Enumerations | Variables
ifx-logger.h File Reference

Generic logging API. More...

#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include "infineon/ifx-error.h"

Go to the source code of this file.

Data Structures

struct  ifx_logger_t
 Generic Logger object used to decapsulate concrete implementation from interface. More...
 

Macros

#define LIB_LOGGER   UINT8_C(0x0C)
 Logger library identifier ID.
 
#define IFX_LOGGER_INITIALIZE   UINT8_C(0x01)
 Reusable IFX error encoding function identifier for any function initializing a Logger.
 
#define IFX_LOGGER_LOG   UINT8_C(0x02)
 Reusable IFX error encoding function identifier for all functions logging data.
 
#define IFX_LOGGER_SET_LEVEL   UINT8_C(0x03)
 IFX error encoding function identifier for ifx_logger_set_level().
 
#define IFX_LOGGER_FORMAT_ERROR   0x01u
 IFX error encoding error reason if error occurred formatting string in ifx_logger_log().
 

Typedefs

typedef ifx_status_t(* ifx_logger_log_callback_t) (const ifx_logger_t *self, const char *source, ifx_log_level level, const char *message)
 Implementation specific log function.
 
typedef ifx_status_t(* ifx_logger_set_level_callback_t) (ifx_logger_t *self, ifx_log_level level)
 Implementation specific log level setter.
 
typedef void(* ifx_logger_destroy_callback_t) (ifx_logger_t *self)
 Implementation specific destructor.
 

Enumerations

enum  ifx_log_level {
  IFX_LOG_DEBUG = 0 , IFX_LOG_INFO = 1 , IFX_LOG_WARN = 2 , IFX_LOG_ERROR = 3 ,
  IFX_LOG_FATAL = 4
}
 Log level for filtering messages to actually be logged. More...
 

Variables

ifx_logger_t * ifx_logger_default
 Default Logger instance to be used.
 

Detailed Description

Generic logging API.

Definition in file ifx-logger.h.

Macro Definition Documentation

◆ IFX_LOGGER_FORMAT_ERROR

#define IFX_LOGGER_FORMAT_ERROR   0x01u

IFX error encoding error reason if error occurred formatting string in ifx_logger_log().

Must be used in combination with IFX_LOGGER_LOG.

Definition at line 49 of file ifx-logger.h.

◆ IFX_LOGGER_INITIALIZE

#define IFX_LOGGER_INITIALIZE   UINT8_C(0x01)

Reusable IFX error encoding function identifier for any function initializing a Logger.

Definition at line 30 of file ifx-logger.h.

◆ IFX_LOGGER_LOG

#define IFX_LOGGER_LOG   UINT8_C(0x02)

Reusable IFX error encoding function identifier for all functions logging data.

Definition at line 36 of file ifx-logger.h.

◆ IFX_LOGGER_SET_LEVEL

#define IFX_LOGGER_SET_LEVEL   UINT8_C(0x03)

IFX error encoding function identifier for ifx_logger_set_level().

Definition at line 41 of file ifx-logger.h.

◆ LIB_LOGGER

#define LIB_LOGGER   UINT8_C(0x0C)

Logger library identifier ID.

Definition at line 24 of file ifx-logger.h.

Typedef Documentation

◆ ifx_logger_destroy_callback_t

typedef void(* ifx_logger_destroy_callback_t) (ifx_logger_t *self)

Implementation specific destructor.

Different loggers may need different clean-up functionality. This function type gives a generic interface for performing clean-up.

Parameters
[in]selfLogger object being destroyed.

Definition at line 222 of file ifx-logger.h.

◆ ifx_logger_log_callback_t

typedef ifx_status_t(* ifx_logger_log_callback_t) (const ifx_logger_t *self, const char *source, ifx_log_level level, const char *message)

Implementation specific log function.

Used by ifx_logger_log() to call concrete implementation.

Parameters
[in]selfLogger object the function was called for.
[in]sourceString with information where the log originated from.
[in]levelifx_log_level of message (used for filtering).
[in]messageFormatted string to be logged.
Returns
ifx_status_t IFX_SUCCESS if successful, any other value in case of error.

Definition at line 168 of file ifx-logger.h.

◆ ifx_logger_set_level_callback_t

typedef ifx_status_t(* ifx_logger_set_level_callback_t) (ifx_logger_t *self, ifx_log_level level)

Implementation specific log level setter.

Used by ifx_logger_set_level() to call concrete implementation. Depending on the logging mechanism used this might wrap to an external library function, etc.

Parameters
[in]selfLogger object to set log level for.
[in]levelMinimum log level of interest.
Returns
ifx_status_t IFX_SUCCESS if successful, any other value in case of error.

Definition at line 197 of file ifx-logger.h.

Enumeration Type Documentation

◆ ifx_log_level

Log level for filtering messages to actually be logged.

Enumerator
IFX_LOG_DEBUG 

Debug information for finding problems in library.

IFX_LOG_INFO 

Information that help trace the program's normal execution flow.

IFX_LOG_WARN 

Information that warns of potential problems.

IFX_LOG_ERROR 

Information about (recoverable) errors.

IFX_LOG_FATAL 

Information about non-recoverable errors.

Definition at line 57 of file ifx-logger.h.

58{
62 IFX_LOG_DEBUG = 0,
63
67 IFX_LOG_INFO = 1,
68
72 IFX_LOG_WARN = 2,
73
77 IFX_LOG_ERROR = 3,
78
ifx_log_level
Log level for filtering messages to actually be logged.
Definition ifx-logger.h:58
@ IFX_LOG_WARN
Information that warns of potential problems.
Definition ifx-logger.h:72
@ IFX_LOG_INFO
Information that help trace the program's normal execution flow.
Definition ifx-logger.h:67
@ IFX_LOG_FATAL
Information about non-recoverable errors.
Definition ifx-logger.h:82
@ IFX_LOG_ERROR
Information about (recoverable) errors.
Definition ifx-logger.h:77
@ IFX_LOG_DEBUG
Debug information for finding problems in library.
Definition ifx-logger.h:62

Variable Documentation

◆ ifx_logger_default

ifx_logger_t* ifx_logger_default
extern

Default Logger instance to be used.

Set via ifx_logger_set_default(), do NOT edit manually.