Go to file
kingecg 7c93a2030c ```
feat(init): 初始化项目并添加基础日志功能

- 添加 .gitignore 忽略 target 目录、*.rs.bk 文件和 Cargo.lock
- 创建 CHANGELOG.md 并记录初始版本 0.1.0 的变更信息
- 在 Cargo.toml 中完善包元数据,包括作者、描述、许可证等信息
- 添加 MIT 许可证文件 LICENSE
- 编写 README.md,介绍项目概览、特性、安装方式和使用示例
```
2025-09-30 00:14:16 +08:00
examples feat(log4r): 初始化项目并实现基础日志功能 2025-09-30 00:06:00 +08:00
src feat(log4r): 初始化项目并实现基础日志功能 2025-09-30 00:06:00 +08:00
.gitignore ``` 2025-09-30 00:14:16 +08:00
CHANGELOG.md ``` 2025-09-30 00:14:16 +08:00
Cargo.lock feat(log4r): 初始化项目并实现基础日志功能 2025-09-30 00:06:00 +08:00
Cargo.toml ``` 2025-09-30 00:14:16 +08:00
LICENSE ``` 2025-09-30 00:14:16 +08:00
README.md ``` 2025-09-30 00:14:16 +08:00

README.md

log4r

A log4j-like logging framework for Rust.

Overview

log4r is a simple, extensible logging framework inspired by log4j. It provides different log levels and an easy-to-use API for Rust applications.

Features

  • Multiple log levels (Trace, Debug, Info, Warn, Error)
  • Simple API similar to log4j
  • Thread-safe logging
  • Timestamped log entries
  • Configurable log levels

Installation

Add this to your Cargo.toml:

[dependencies]
log4r = "0.1"

Example

use log4r::{LogLevel, Logger};

fn main() {
    // Initialize the logger with Debug level
    Logger::init(LogLevel::Debug);
    
    // Test all log levels
    log4r::trace!("This is a trace message - won't be printed");
    log4r::debug!("This is a debug message - will be printed");
    log4r::info!("This is an info message - will be printed");
    log4r::warn!("This is a warning message - will be printed");
    log4r::error!("This is an error message - will be printed");
}

License

This project is licensed under the MIT License - see the LICENSE file for details.