```
feat(init): 初始化项目并添加基础日志功能 - 添加 .gitignore 忽略 target 目录、*.rs.bk 文件和 Cargo.lock - 创建 CHANGELOG.md 并记录初始版本 0.1.0 的变更信息 - 在 Cargo.toml 中完善包元数据,包括作者、描述、许可证等信息 - 添加 MIT 许可证文件 LICENSE - 编写 README.md,介绍项目概览、特性、安装方式和使用示例 ```
This commit is contained in:
parent
175c50654d
commit
7c93a2030c
|
|
@ -1 +1,3 @@
|
|||
/target
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.1.0] - 2025-09-30
|
||||
|
||||
### Added
|
||||
|
||||
- Initial release of log4r
|
||||
- Basic logging functionality with five log levels (Trace, Debug, Info, Warn, Error)
|
||||
- Thread-safe logger implementation
|
||||
- Simple API inspired by log4j
|
||||
- Examples for basic and advanced usage
|
||||
|
|
@ -2,6 +2,15 @@
|
|||
name = "log4r"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
authors = ["log4r contributors"]
|
||||
description = "A log4j-like logging framework for Rust"
|
||||
license = "MIT"
|
||||
repository = "https://git.kingecg.top/kingecg/log4r.git"
|
||||
homepage = "https://git.kingecg.top/kingecg/log4r.git"
|
||||
documentation = "https://docs.rs/log4r"
|
||||
keywords = ["logging", "log4j", "log"]
|
||||
categories = ["development-tools::debugging"]
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.42"
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2025 log4r contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
# 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`:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
log4r = "0.1"
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```rust
|
||||
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](LICENSE) file for details.
|
||||
Loading…
Reference in New Issue