chore: RDEPUBBackgroundTrace 日志默认关闭
Release 构建下完全静默(isEnabled 固定 false), Debug 构建下通过 _enabled 开关控制,默认开启。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
2fa58b1026
commit
8c5059e72f
@ -2,8 +2,18 @@ import Foundation
|
|||||||
|
|
||||||
enum RDEPUBBackgroundTrace {
|
enum RDEPUBBackgroundTrace {
|
||||||
|
|
||||||
static func log(_ scope: String, _ message: String) {
|
static var isEnabled: Bool {
|
||||||
|
#if DEBUG
|
||||||
|
return _enabled
|
||||||
|
#else
|
||||||
|
return false
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static var _enabled = true
|
||||||
|
|
||||||
|
static func log(_ scope: String, _ message: String) {
|
||||||
|
guard isEnabled else { return }
|
||||||
let threadRole = Thread.isMainThread ? "main" : "bg"
|
let threadRole = Thread.isMainThread ? "main" : "bg"
|
||||||
|
|
||||||
let threadName = resolvedThreadName()
|
let threadName = resolvedThreadName()
|
||||||
@ -13,7 +23,7 @@ enum RDEPUBBackgroundTrace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static func measure<T>(_ scope: String, _ message: String, work: () throws -> T) rethrows -> T {
|
static func measure<T>(_ scope: String, _ message: String, work: () throws -> T) rethrows -> T {
|
||||||
|
guard isEnabled else { return try work() }
|
||||||
let startedAt = CFAbsoluteTimeGetCurrent()
|
let startedAt = CFAbsoluteTimeGetCurrent()
|
||||||
log(scope, "START \(message)")
|
log(scope, "START \(message)")
|
||||||
do {
|
do {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user