Files
duooomi-ios-sdk/Sources/DuooomiBleSDK/DuooomiBleConfig.swift
km2023 6ed3c555df 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>
2026-05-20 16:02:28 +08:00

52 lines
2.0 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Foundation
/// SDK
public struct DuooomiBleConfig {
/// API
public let apiHost: URL
/// API keyLoomart x-api-key
public let apiKey: String
/// RPC `x-owner` header
public let brand: String
/// CDN `/`
public let cdnHost: String
/// ANI
public let aniWidth: Int
/// ANI
public let aniHeight: Int
/// ANI
public let aniFps: String
/// 广****广
public let scanNamePrefix: String
/// `[0, 500]` warn使 clamp
/// / 35
public let frameIntervalMs: Int
/// SDK `.off` `.warn` `.debug`
/// Release `#if DEBUG` level
public let logLevel: BleLogLevel
public init(
apiHost: URL = URL(string: "https://api.duooomi.com")!,
apiKey: String,
brand: String,
cdnHost: String = "https://cdn.bowong.cc/",
aniWidth: Int = 360,
aniHeight: Int = 360,
aniFps: String = "24",
scanNamePrefix: String,
frameIntervalMs: Int = 35,
logLevel: BleLogLevel = .off
) {
self.apiHost = apiHost
self.apiKey = apiKey
self.brand = brand
self.cdnHost = cdnHost.hasSuffix("/") ? cdnHost : cdnHost + "/"
self.aniWidth = aniWidth
self.aniHeight = aniHeight
self.aniFps = aniFps
self.scanNamePrefix = scanNamePrefix
self.frameIntervalMs = frameIntervalMs
self.logLevel = logLevel
}
}