# mini_log **Repository Path**: solawc/mini_log ## Basic Information - **Project Name**: mini_log - **Description**: 轻量级嵌入式日志库 (Lightweight Embedded Logging Library) - **Primary Language**: Unknown - **License**: GPL-3.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-17 - **Last Updated**: 2026-03-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: log, printf ## README # mini_log A Lightweight Embedded Logging Library ## Introduction mini_log is a lightweight logging library designed specifically for embedded systems, offering flexible log level control and customizable output functionality. With minimal resource consumption and a simple interface, it is ideal for resource-constrained embedded development environments. ## Features - **Multi-level Logging**: Supports multiple log levels - **Customizable Output**: Configurable log output callback function - **Formatted Output**: Supports printf-style formatted logging - **Buffer Printing**: Supports direct printing of binary data buffers - **Dynamic Level Control**: Supports runtime adjustment of log levels ## API Interfaces ### Initialization ```c void log_init(log_level_t level, log_output_func_t output_func); ``` Initializes the logging system, setting the default log level and output function. ### Set Log Level ```c void log_set_level(log_level_t level); ``` Dynamically adjusts the log output level. ### Formatted Log Output ```c void log_printf(log_level_t level, const char *fmt, ...); ``` printf-style formatted log output. ### Buffer Data Printing ```c void log_print_buffer(log_level_t level, const uint8_t *data, uint32_t len); ``` Prints binary data in hexadecimal format for easy debugging. ## Usage Example ```c #include "mini_log.h" // Custom output function void my_output(const uint8_t *data, uint16_t len) { // Send data to UART, USB, or other output device uart_send(data, len); } int main(void) { // Initialize the logging system log_init(LOG_LEVEL_DEBUG, my_output); // Set log level log_set_level(LOG_LEVEL_INFO); // Use logging log_printf(LOG_LEVEL_INFO, "System started\n"); log_printf(LOG_LEVEL_DEBUG, "Value: %d\n", 42); // Print buffer uint8_t buffer[] = {0x01, 0x02, 0x03, 0x04}; log_print_buffer(LOG_LEVEL_DEBUG, buffer, sizeof(buffer)); return 0; } ``` ## Log Levels Typical levels included (subject to specific implementation): - `LOG_LEVEL_ERROR` - Error messages - `LOG_LEVEL_WARN` - Warning messages - `LOG_LEVEL_INFO` - General information - `LOG_LEVEL_DEBUG` - Debug information ## Configuration Notes Adjust the `LOG_BUFF_SIZE` macro to modify the log buffer size according to your system's resource requirements. ## License This project is licensed under an open-source license. Please refer to the LICENSE file in the project root directory for details. ## Contribution Guidelines Issues and pull requests are welcome to help improve this project.