当然!以下是您的 LogManager Swift 包的 README.md 文件。该文件包含有关如何使用该包、将其集成到项目中以及概述其功能的说明。
# LogManager
LogManager is a Swift package that provides an easy-to-use logging system. It allows you to create log files, manage log retention, zip log files, and present a share sheet to share the zipped logs. The logs include a timestamp with date, time, and region for better context.
## Features
- Log messages with timestamps and custom topics.
- Rotate logs to keep only the last N days of logs (configurable).
- Zip log files for easy sharing.
- Present a share sheet to share the zipped logs.
## Requirements
- iOS 13.0+
- Swift 5.3+
## Installation
### Swift Package Manager
You can add LogManager to your project using Swift Package Manager.
1. **File > Swift Packages > Add Package Dependency...**
2. Enter the repository URL: `https://github.com/prabhatk/LogManager.git`
3. Follow the prompts to add the package to your project.
Alternatively, you can add it directly to your `Package.swift` file:
```swift
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "YourApp",
dependencies: [
.package(url: "https://github.com/your-username/LogManager.git", from: "1.0.0"),
],
targets: [
.target(
name: "YourApp",
dependencies: ["LogManager"]),
]
)
import LogManager
LogManager.shared.log(topic: "AppLifecycle", message: "App started")
LogManager.shared.log(topic: "UserEvent", message: "User logged in")
设置保留日志文件的最大天数
LogManager.shared.setMaxDays(7)
if let zipFileURL = LogManager.shared.zipLogs() {
print("Zipped logs are available at: \(zipFileURL)")
}
本项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。
### Explanation
- **Title and Features:** Provides an overview of the package and its key features.
- **Requirements:** Specifies the platform and Swift version requirements.
- **Installation:** Instructions for adding the package using Swift Package Manager.
- **Usage:** Demonstrates how to import, log messages, configure log retention and zip log files.
- **License:** Mentions the license for the project.
You can customize the repository URL and other details as needed. This `README.md` file will help users understand how to use your `LogManager` package effectively.