Logging API

Module: Utils API

Types

Name

typedef void(*)(const char *str)

Log_StringOutputType
Callback function to direct string log output to a user-defined console.

typedef void(*)(const char ch)

Log_CharOutputType
Callback function to direct single character log output to a user-defined console.

Defines

Name

LOG_ERROR_NONE
No error.

LOG_ERROR_NOT_INIT
Log module not initialized.

LOG_ERROR_INVALID_CB_FXN
Invalid callback function, e.g. NULL handler.

LOG_ERROR_INIT_FAILED
Log module initialization failed.

LOG_ERROR_LOCK_FAILED
Log module lock failed.

LOG_INIT()
Initializes the logging module.

LOG_REGISTER_OUTPUT(outputCb)
Registers a callback function for log output.

LOG(format, …)
Outputs a message to the registered log output.

LOG_CHAR(ch)
Outputs a character to the registered log output.

LOG_ASSERT(cond, format, …)
Assert check with Logs.

Types Documentation

typedef Log_StringOutputType

typedef void(* Log_StringOutputType) (const char *str);

Callback function to direct string log output to a user-defined console.

Parameters:

  • str string to be sent to the console

typedef Log_CharOutputType

typedef void(* Log_CharOutputType) (const char ch);

Callback function to direct single character log output to a user-defined console.

Parameters:

  • ch character to be sent to the console

Macros Documentation

define LOG_ERROR_NONE

#define LOG_ERROR_NONE (0)

No error.

define LOG_ERROR_NOT_INIT

#define LOG_ERROR_NOT_INIT (1)

Log module not initialized.

define LOG_ERROR_INVALID_CB_FXN

#define LOG_ERROR_INVALID_CB_FXN (2)

Invalid callback function, e.g. NULL handler.

define LOG_ERROR_INIT_FAILED

#define LOG_ERROR_INIT_FAILED (3)

Log module initialization failed.

define LOG_ERROR_LOCK_FAILED

#define LOG_ERROR_LOCK_FAILED (4)

Log module lock failed.

define LOG_INIT

#define LOG_INIT(
    
)
(void)0

Initializes the logging module.

This function sets up the logging module for use. It must be called before any other logging functions are used.

define LOG_REGISTER_OUTPUT

#define LOG_REGISTER_OUTPUT(
    outputCb
)
(void)0

Registers a callback function for log output.

Parameters:

  • outputCb The callback function to handle log output

Return: [Log_ErrorType]

This API is not thread safe and recommended to be called during system initialization.

define LOG

#define LOG(
    format,
    ...
)
(void)0

Outputs a message to the registered log output.

define LOG_CHAR

#define LOG_CHAR(
    ch
)
(void)0

Outputs a character to the registered log output.

define LOG_ASSERT

#define LOG_ASSERT(
    cond,
    format,
    ...
)
    if (!(cond))                      \
    {                                 \
        while (1)                     \
            ;                         \
    }

Assert check with Logs.