You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
1 year ago | |
|---|---|---|
| .. | ||
| Classes | 1 year ago | |
| README.md | 1 year ago | |
| deepvoice_utils.podspec | 1 year ago | |
README.md
DeepVoice Utils iOS 实现
简介
本模块是 deepvoice_utils 插件的 iOS 实现部分,主要提供以下功能:
- 文件日志记录(FileLogger):将日志记录到文件,方便调试和问题排查
使用说明
日志系统
该插件自动初始化日志系统,开发者无需手动调用初始化方法。日志文件默认保存在应用的 Documents 目录下的 logs 文件夹中,按日期分文件存储。
配置要求
- iOS 11.0 或更高版本
- Swift 5.0
- 确保应用拥有文件写入权限
开发说明
文件结构
DeepvoiceUtilsPlugin.swift:插件主类,负责与 Flutter 交互FileLogger.swift:日志系统实现,提供日志记录功能SwiftDeepvoiceUtilsPlugin.swift:命名约定桥接类DeepvoiceUtilsPlugin.h/.m:Objective-C 桥接文件
自定义日志目录
如需使用自定义日志目录,可以在应用启动时手动调用初始化方法:
import deepvoice_utils
// 在 AppDelegate 中
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// 自定义日志目录
let customDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("custom_logs")
FileLogger.initialize(withDirectory: customDirectory)
return true
}
清理旧日志
默认情况下,日志系统不会自动清理旧日志。如果需要清理,可以手动调用:
// 清理7天前的日志
FileLogger.cleanOldLogs(daysToKeep: 7)