feat(sdk): 同步 iOS — 日志等级 logLevel 配置化(默认 OFF)
BleLog 之前所有调用都无条件 Log.d/i/w/e,集成方没法关。新增 public enum BleLogLevel(OFF/ERROR/WARN/INFO/DEBUG),通过 DuooomiBleConfig.logLevel 传入,DuooomiBleSDK init 块第一行写入 BleLog.level。默认 OFF 保证对外集成默认静默。 frameIntervalMs 越界 warn 从 DuooomiBleConfig.init 挪到 DuooomiBleSDK init 内、level 设置之后,避免在 level 写入前丢日志。 平台差异:Android 没有 iOS 的 #if DEBUG 编译期消除;默认 OFF 已足够 静默,如需硬剥离 android.util.Log 可在宿主 ProGuard/R8 加 -assumenosideeffects(README 已说明)。 对齐 ios:6ed3c55。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
21
README.md
21
README.md
@@ -100,6 +100,7 @@ val sdk = DuooomiBleSDK(
|
||||
apiKey = "YOUR_API_KEY",
|
||||
brand = "YOUR_BRAND", // 设备品牌名,所有 RPC 必带
|
||||
scanNamePrefix = "Duooomi-" // 扫描时按广播名前缀过滤
|
||||
// logLevel = BleLogLevel.OFF // 日志等级,默认 OFF(完全静默),排查时改 DEBUG
|
||||
)
|
||||
)
|
||||
```
|
||||
@@ -115,6 +116,26 @@ val sdk = DuooomiBleSDK(
|
||||
| `cdnHost` | | 默认 `https://cdn.bowong.cc/` |
|
||||
| `aniWidth` / `aniHeight` / `aniFps` | | ANI 转换参数,默认 `360 / 360 / "24"` |
|
||||
| `frameIntervalMs` | | 协议帧之间发送间隔(ms),默认 `35`,合法 `[0, 500]`;越界仅 warn,使用点 `coerceIn`。调高用于排查接收端丢帧 |
|
||||
| `logLevel` | | 日志等级(`BleLogLevel.OFF/ERROR/WARN/INFO/DEBUG`),默认 `OFF`。详见下文 |
|
||||
|
||||
### 5. 日志(BleLogLevel)
|
||||
|
||||
SDK 内部所有日志统一走 `BleLog` → `android.util.Log`,分级 `OFF / ERROR / WARN / INFO / DEBUG`。集成方通过 `config.logLevel` 控制输出:
|
||||
|
||||
```kotlin
|
||||
// 对外发布:什么都不传,默认完全静默
|
||||
DuooomiBleSDK(context, DuooomiBleConfig(apiKey = "...", brand = "...", scanNamePrefix = "..."))
|
||||
|
||||
// 本地排查:开 DEBUG 看到所有 BLE 帧、RPC opId、传输进度等
|
||||
DuooomiBleSDK(context, DuooomiBleConfig(
|
||||
apiKey = "...", brand = "...", scanNamePrefix = "...",
|
||||
logLevel = BleLogLevel.DEBUG
|
||||
))
|
||||
```
|
||||
|
||||
- 等级单调:`WARN` 输出 warn + error;`INFO` 输出 info + warn + error;以此类推。
|
||||
- 日志按 category 分桶:`SDK / Scan / Connect / BLE / RPC / Command / Transfer / Firmware / Protocol / Decode / Config`,Logcat 按 tag `DuooomiBleSDK` + `[<category>]` 过滤。
|
||||
- **Release 包剥离 `Log.d/i`**:Android 平台没有 iOS `#if DEBUG` 那样的编译期消除,默认 `OFF` 已足够静默;如需彻底剥离 `android.util.Log` 调用,可在宿主 ProGuard/R8 配置中加 `-assumenosideeffects class android.util.Log { public static *** d(...); public static *** i(...); }`。
|
||||
|
||||
## API 参考
|
||||
|
||||
|
||||
Reference in New Issue
Block a user