feat(sdk): 日志等级 logLevel 配置化(默认 .off,对外发布完全静默)
BleLog 之前所有调用都无条件 print(Debug 包),集成方没法关。新增 public enum BleLogLevel(off/error/warn/info/debug),通过 DuooomiBleConfig.logLevel 传入,DuooomiBleSDK.init 第一行写入 BleLog.level。默认 .off 保证对外集成默认静默,排查时显式开 .debug。 保留 #if DEBUG 兜底,Release 任何 level 都不输出。 frameIntervalMs 越界 warn 从 DuooomiBleConfig.init 挪到 DuooomiBleSDK.init 内、level 设置之后,避免在 level 写入前丢日志。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
17
README.md
17
README.md
@@ -47,11 +47,28 @@ let sdk = DuooomiBleSDK(config: .init(
|
||||
// cdnHost: "https://cdn.bowong.cc/", // 默认
|
||||
// aniWidth: 360, aniHeight: 360, aniFps: "24", // ANI 转换默认参数
|
||||
// frameIntervalMs: 35, // 协议帧间隔(ms),合法 [0,500],越界 warn 后 clamp
|
||||
// logLevel: .off, // 日志等级,默认 .off(完全静默),排查时改 .debug
|
||||
))
|
||||
|
||||
sdk.delegate = self
|
||||
```
|
||||
|
||||
### 日志(BleLogLevel)
|
||||
|
||||
SDK 内部所有日志统一走 `BleLog` → `print`,分级 `off / error / warn / info / debug`。集成方通过 `config.logLevel` 控制输出:
|
||||
|
||||
```swift
|
||||
// 对外发布:什么都不传,默认完全静默
|
||||
DuooomiBleSDK(config: .init(apiKey: ..., brand: ..., scanNamePrefix: ...))
|
||||
|
||||
// 本地排查:开 debug 看到所有 BLE 帧、RPC opId、传输进度等
|
||||
DuooomiBleSDK(config: .init(apiKey: ..., brand: ..., scanNamePrefix: ..., logLevel: .debug))
|
||||
```
|
||||
|
||||
- 等级单调:`.warn` 会输出 warn + error;`.info` 输出 info + warn + error;以此类推。
|
||||
- **Release 构建因 `#if DEBUG` 条件编译,任何 `logLevel` 都不会输出**(双保险)。
|
||||
- 日志按 category 分桶:`SDK / Scan / Connect / BLE / RPC / Command / Transfer / Firmware / Protocol / Decode / Config`,Xcode console 可按 `[DuooomiBleSDK][<category>]` 过滤。
|
||||
|
||||
## SDK 能力范围
|
||||
|
||||
- **内置**:BLE 协议(扫描/连接/绑定/解绑/播放模式/文件传输/OTA 烧录)+ 固件版本检查
|
||||
|
||||
Reference in New Issue
Block a user