#include <stdint.h>#include <string.h>#include <stdio.h>Go to the source code of this file.
Data Structures | |
| struct | hpm_log_engine_config |
| struct | hpm_log_config |
Macros | |
| #define | HPM_LOG_CONFIG_MAX_ENGINE_NUM 1 |
| Maximum number of log engines. More... | |
| #define | HPM_LOG_CONFIG_MAX_MESSAGE_LEN 256 |
| Maximum length of a log message. More... | |
| #define | HPM_LOG_CONFIG_ENABLE_TIMESTAMP 1 |
| Enable timestamp in log messages. More... | |
| #define | HPM_LOG_CONFIG_ENABLE_FUNC_NAME 1 |
| Enable function name in log messages. More... | |
| #define | HPM_LOG_CONFIG_LEVEL HPM_LOG_LEVEL_DEBUG |
| Log level configuration. More... | |
| #define | HPM_LOG_FAST_FUNC |
| Indicate fast functions. More... | |
| #define | HPM_LOG_LEVEL_DEBUG 4 |
| Debug log level. More... | |
| #define | HPM_LOG_LEVEL_INFO 3 |
| Information log level. More... | |
| #define | HPM_LOG_LEVEL_WARN 2 |
| Warning log level. More... | |
| #define | HPM_LOG_LEVEL_ERR 1 |
| Error log level. More... | |
| #define | HPM_LOG_PRINTF(fmt, ...) hpm_log_printf(fmt, ##__VA_ARGS__); |
| Macro to print a formatted log message. More... | |
| #define | HPM_LOG_DEBUG(fmt, ...) |
| Macro to log a debug message. More... | |
| #define | HPM_LOG_INFO(fmt, ...) |
| Macro to log an information message. More... | |
| #define | HPM_LOG_WARN(fmt, ...) |
| Macro to log a warning message. More... | |
| #define | HPM_LOG_ERR(fmt, ...) |
| Macro to log an error message. More... | |
Typedefs | |
| typedef struct hpm_log_engine | hpm_log_engine_t |
| Forward declaration of the log engine structure. More... | |
| typedef struct hpm_log_engine_config | hpm_log_engine_config_t |
| typedef struct hpm_log_config | hpm_log_config_t |
Functions | |
| hpm_log_engine_t * | hpm_log_engine_create (hpm_log_engine_config_t *cfg) |
| Create a log engine. More... | |
| int | hpm_log_engine_destroy (hpm_log_engine_t *engine) |
| Destroy a log engine. More... | |
| void | hpm_log_engine_enable (hpm_log_engine_t *engine) |
| Enable a log engine. More... | |
| void | hpm_log_engine_disable (hpm_log_engine_t *engine) |
| Disable a log engine. More... | |
| void | hpm_log_engine_transfer_finish (hpm_log_engine_t *engine) |
| Indicate that the transfer of a log message is finished. More... | |
| void | hpm_log_engine_dump (hpm_log_engine_t *engine) |
| Dump all log messages in the FIFO buffer. More... | |
| void | hpm_log_init (hpm_log_config_t *cfg) |
| Initialize the log module. More... | |
| void | hpm_log_printf (const char *fmt,...) |
| Print a formatted log message. More... | |
| void | hpm_log_write (int level, const char *func, const int line, const char *fmt,...) |
| Write a log message with a specified level. More... | |
| #define HPM_LOG_CONFIG_ENABLE_FUNC_NAME 1 |
Enable function name in log messages.
This macro controls whether function names are included in log messages. If set to 1, function names will be included; if set to 0, they will be omitted. If not defined externally, the default value is 1.
| #define HPM_LOG_CONFIG_ENABLE_TIMESTAMP 1 |
Enable timestamp in log messages.
This macro controls whether timestamps are included in log messages. If set to 1, timestamps will be included; if set to 0, they will be omitted. If not defined externally, the default value is 1.
| #define HPM_LOG_CONFIG_LEVEL HPM_LOG_LEVEL_DEBUG |
Log level configuration.
This macro defines the current log level. Log messages with a level lower than this configuration will be ignored. If not defined externally, the default value is HPM_LOG_LEVEL_DEBUG.
| #define HPM_LOG_CONFIG_MAX_ENGINE_NUM 1 |
Maximum number of log engines.
This macro defines the maximum number of log engines that can be created. If not defined externally, the default value is 1.
| #define HPM_LOG_CONFIG_MAX_MESSAGE_LEN 256 |
Maximum length of a log message.
This macro defines the maximum length of a log message. If not defined externally, the default value is 256.
| #define HPM_LOG_DEBUG | ( | fmt, | |
| ... | |||
| ) |
Macro to log a debug message.
This macro logs a debug message if the current log level is set to HPM_LOG_LEVEL_DEBUG or higher.
| fmt | Format string for the debug message. |
| ... | Variable arguments corresponding to the format string. |
| #define HPM_LOG_ERR | ( | fmt, | |
| ... | |||
| ) |
Macro to log an error message.
This macro logs an error message if the current log level is set to HPM_LOG_LEVEL_ERR or higher.
| fmt | Format string for the error message. |
| ... | Variable arguments corresponding to the format string. |
| #define HPM_LOG_FAST_FUNC |
Indicate fast functions.
This macro is used to mark functions that are expected to be fast.
| #define HPM_LOG_INFO | ( | fmt, | |
| ... | |||
| ) |
Macro to log an information message.
This macro logs an information message if the current log level is set to HPM_LOG_LEVEL_INFO or higher.
| fmt | Format string for the information message. |
| ... | Variable arguments corresponding to the format string. |
| #define HPM_LOG_LEVEL_DEBUG 4 |
Debug log level.
This macro represents the debug log level. It is used for detailed debugging information.
| #define HPM_LOG_LEVEL_ERR 1 |
Error log level.
This macro represents the error log level. It is used for critical error messages.
| #define HPM_LOG_LEVEL_INFO 3 |
Information log level.
This macro represents the information log level. It is used for general information messages.
| #define HPM_LOG_LEVEL_WARN 2 |
Warning log level.
This macro represents the warning log level. It is used for non-critical warnings.
| #define HPM_LOG_PRINTF | ( | fmt, | |
| ... | |||
| ) | hpm_log_printf(fmt, ##__VA_ARGS__); |
Macro to print a formatted log message.
This macro calls the hpm_log_printf function with the specified format string and arguments.
| fmt | Format string for the log message. |
| ... | Variable arguments corresponding to the format string. |
| #define HPM_LOG_WARN | ( | fmt, | |
| ... | |||
| ) |
Macro to log a warning message.
This macro logs a warning message if the current log level is set to HPM_LOG_LEVEL_WARN or higher.
| fmt | Format string for the warning message. |
| ... | Variable arguments corresponding to the format string. |
| typedef struct hpm_log_config hpm_log_config_t |
| typedef struct hpm_log_engine_config hpm_log_engine_config_t |
Forward declaration of the log engine structure.
| hpm_log_engine_t* hpm_log_engine_create | ( | hpm_log_engine_config_t * | cfg | ) |
Create a log engine.
This function creates a new log engine with the specified configuration.
| cfg | Pointer to the log engine configuration structure. |
| int hpm_log_engine_destroy | ( | hpm_log_engine_t * | engine | ) |
Destroy a log engine.
This function destroys the specified log engine and releases its resources.
| engine | Pointer to the log engine to be destroyed. |
| void hpm_log_engine_disable | ( | hpm_log_engine_t * | engine | ) |
Disable a log engine.
This function disables the specified log engine, preventing it from processing log messages.
| engine | Pointer to the log engine to be disabled. |
| void hpm_log_engine_dump | ( | hpm_log_engine_t * | engine | ) |
Dump all log messages in the FIFO buffer.
This function transfers all log messages currently in the FIFO buffer of the specified log engine.
| engine | Pointer to the log engine whose FIFO buffer should be dumped. |
| void hpm_log_engine_enable | ( | hpm_log_engine_t * | engine | ) |
Enable a log engine.
This function enables the specified log engine, allowing it to start processing log messages.
| engine | Pointer to the log engine to be enabled. |
| void hpm_log_engine_transfer_finish | ( | hpm_log_engine_t * | engine | ) |
Indicate that the transfer of a log message is finished.
This function is called to indicate that the transfer of a log message has finished. It may trigger the transfer of the next message in the FIFO buffer.
| engine | Pointer to the log engine for which the transfer has finished. |
| void hpm_log_init | ( | hpm_log_config_t * | cfg | ) |
Initialize the log module.
This function initializes the log module with the specified configuration.
| cfg | Pointer to the log module configuration structure. if NULL, the default is used. |
| void hpm_log_printf | ( | const char * | fmt, |
| ... | |||
| ) |
Print a formatted log message.
This function prints a formatted log message using the specified format string and arguments.
| fmt | Format string for the log message. |
| ... | Variable arguments corresponding to the format string. |
| void hpm_log_write | ( | int | level, |
| const char * | func, | ||
| const int | line, | ||
| const char * | fmt, | ||
| ... | |||
| ) |
Write a log message with a specified level.
This function writes a log message with the specified log level, function name, line number, and format string and arguments.
| level | Log level of the message. |
| func | Name of the function where the log message is generated. |
| line | Line number in the source file where the log message is generated. |
| fmt | Format string for the log message. |
| ... | Variable arguments corresponding to the format string. |