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:
@@ -108,6 +108,7 @@ public final class DuooomiBleSDK: NSObject {
|
||||
// MARK: - Init
|
||||
|
||||
public init(config: DuooomiBleConfig) {
|
||||
BleLog.level = config.logLevel
|
||||
self.config = config
|
||||
bleClient = BleClient()
|
||||
protocolService = BleProtocolService(client: bleClient, frameIntervalMs: config.frameIntervalMs)
|
||||
@@ -122,7 +123,10 @@ public final class DuooomiBleSDK: NSObject {
|
||||
super.init()
|
||||
|
||||
protocolService.delegate = self
|
||||
BleLog.i("SDK initialized (apiHost=\(config.apiHost), brand=\(config.brand))", "SDK")
|
||||
BleLog.i("SDK initialized (apiHost=\(config.apiHost), brand=\(config.brand), logLevel=\(config.logLevel))", "SDK")
|
||||
if config.frameIntervalMs < 0 || config.frameIntervalMs > 500 {
|
||||
BleLog.w("frameIntervalMs=\(config.frameIntervalMs) out of [0,500], will clamp at use site", "Config")
|
||||
}
|
||||
setupDisconnectHandler()
|
||||
|
||||
// UpgradeRecord 变化(含对账上报结果)→ delegate 通知
|
||||
|
||||
Reference in New Issue
Block a user