Skip to content

Commit 8982255

Browse files
authored
Merge pull request #1070 from DimensionDev/ios/20250627
Ios/20250627
2 parents 9bad9f6 + 1c7d6ca commit 8982255

File tree

54 files changed

+493
-498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+493
-498
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import Foundation
2+
3+
4+
public struct FlareLog {
5+
6+
/// 调试日志输出
7+
/// - Parameter message: 要输出的消息
8+
/// - Note: 只在Debug模式下输出,Release模式下完全不执行
9+
public static func debug(_ message: String) {
10+
#if DEBUG
11+
print("🔍 [Flare] \(message)")
12+
#endif
13+
}
14+
15+
/// 信息日志输出
16+
/// - Parameter message: 要输出的消息
17+
/// - Note: 只在Debug模式下输出,Release模式下完全不执行
18+
public static func info(_ message: String) {
19+
#if DEBUG
20+
print("ℹ️ [Flare] \(message)")
21+
#endif
22+
}
23+
24+
/// 警告日志输出
25+
/// - Parameter message: 要输出的消息
26+
/// - Note: 只在Debug模式下输出,Release模式下完全不执行
27+
public static func warning(_ message: String) {
28+
#if DEBUG
29+
print("⚠️ [Flare] \(message)")
30+
#endif
31+
}
32+
33+
/// 错误日志输出
34+
/// - Parameter message: 要输出的消息
35+
/// - Note: 在Debug和Release模式下都会输出,用于记录关键错误
36+
public static func error(_ message: String) {
37+
print("❌ [Flare] \(message)")
38+
}
39+
40+
/// 性能相关日志输出
41+
/// - Parameter message: 要输出的消息
42+
/// - Note: 只在Debug模式下输出,用于性能调试
43+
public static func performance(_ message: String) {
44+
#if DEBUG
45+
print("⚡ [Flare] \(message)")
46+
#endif
47+
}
48+
}

iosApp/iosApp/Common/Performance/FloatingWindow/FloatingPerformanceWindow.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,11 @@ struct TimelinePerformanceTestSection: View {
460460
// MARK: - Test Control Methods
461461

462462
private func startPerformanceTest() {
463-
print("🚀 [PerformanceTest] Starting performance test for \(versionManager.currentVersion.rawValue)")
463+
FlareLog.performance("PerformanceTest Starting performance test for \(versionManager.currentVersion.rawValue)")
464464

465465
// 确保性能监控正在运行
466466
if !monitor.isMonitoring {
467-
print("📊 [PerformanceTest] Starting performance monitoring")
467+
FlareLog.performance("PerformanceTest Starting performance monitoring")
468468
monitor.startMonitoring()
469469
}
470470

@@ -477,11 +477,11 @@ struct TimelinePerformanceTestSection: View {
477477
// 启动数据收集定时器
478478
startDataCollection()
479479

480-
print("⏱️ [PerformanceTest] Test started - will run until manually stopped")
480+
FlareLog.performance("PerformanceTest Test started - will run until manually stopped")
481481
}
482482

483483
private func stopPerformanceTest() {
484-
print("🛑 [PerformanceTest] Stopping performance test")
484+
FlareLog.performance("PerformanceTest Stopping performance test")
485485

486486
isTestRunning = false
487487
stopDataCollection()
@@ -490,14 +490,14 @@ struct TimelinePerformanceTestSection: View {
490490
showResults = true
491491

492492
if let result {
493-
print("📈 [PerformanceTest] Test completed - FPS: \(String(format: "%.1f", result.averageFPS)), Grade: \(result.performanceGrade)")
493+
FlareLog.performance("PerformanceTest Test completed - FPS: \(String(format: "%.1f", result.averageFPS)), Grade: \(result.performanceGrade)")
494494
}
495495
}
496496

497497
// MARK: - Data Collection
498498

499499
private func startDataCollection() {
500-
print("📊 [PerformanceTest] Starting data collection timer")
500+
FlareLog.performance("PerformanceTest Starting data collection timer")
501501

502502
// 使用标准化的数据收集间隔
503503
dataCollectionTimer = Timer.scheduledTimer(withTimeInterval: PerformanceConfig.performanceTestDataInterval, repeats: true) { _ in
@@ -506,7 +506,7 @@ struct TimelinePerformanceTestSection: View {
506506
}
507507

508508
private func stopDataCollection() {
509-
print("📊 [PerformanceTest] Stopping data collection timer")
509+
FlareLog.performance("PerformanceTest Stopping data collection timer")
510510
dataCollectionTimer?.invalidate()
511511
dataCollectionTimer = nil
512512
}
@@ -524,7 +524,7 @@ struct TimelinePerformanceTestSection: View {
524524

525525
// 调试输出(每10次输出一次,避免日志过多)
526526
if Int.random(in: 1 ... 20) == 1 {
527-
print("📊 [PerformanceTest] Data: FPS=\(String(format: "%.1f", fps)), CPU=\(String(format: "%.1f", cpu))%, MEM=\(String(format: "%.1f", memoryMB))MB")
527+
FlareLog.performance("PerformanceTest Data: FPS=\(String(format: "%.1f", fps)), CPU=\(String(format: "%.1f", cpu))%, MEM=\(String(format: "%.1f", memoryMB))MB")
528528
}
529529
}
530530
}

iosApp/iosApp/Common/Performance/FloatingWindow/FloatingWindowManager.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,26 @@ class FloatingWindowManager: ObservableObject {
4444
func show() {
4545
// 添加调试日志
4646
if PerformanceConfig.isVerboseLoggingEnabled {
47-
print("[FloatingWindow] 🚀 Show window called, Debug mode enabled: \(PerformanceConfig.isDebugModeEnabled)")
47+
FlareLog.debug("FloatingWindow Show window called, Debug mode enabled: \(PerformanceConfig.isDebugModeEnabled)")
4848
}
4949

5050
// 只在Debug模式下显示
5151
guard PerformanceConfig.isDebugModeEnabled else {
5252
if PerformanceConfig.isVerboseLoggingEnabled {
53-
print("[FloatingWindow] ❌ Debug mode disabled, window not shown")
53+
FlareLog.debug("FloatingWindow Debug mode disabled, window not shown")
5454
}
5555
return
5656
}
5757

5858
if PerformanceConfig.isVerboseLoggingEnabled {
59-
print("[FloatingWindow] ✅ Showing floating window in expanded state")
59+
FlareLog.debug("FloatingWindow Showing floating window in expanded state")
6060
}
6161

6262
// 确保性能监控已启动
6363
let monitor = TimelinePerformanceMonitor.shared
6464
if !monitor.isMonitoring {
6565
if PerformanceConfig.isVerboseLoggingEnabled {
66-
print("[FloatingWindow] 📊 Starting performance monitoring")
66+
FlareLog.debug("FloatingWindow Starting performance monitoring")
6767
}
6868
monitor.startMonitoring()
6969
}

iosApp/iosApp/Common/Performance/FloatingWindow/FloatingWindowOverlay.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,37 +59,37 @@ struct FloatingWindowControlPanel: View {
5959
HStack {
6060
Button(action: {
6161
if PerformanceConfig.isVerboseLoggingEnabled {
62-
print("[FloatingWindowControl] 🔘 Show/Hide button tapped")
63-
print("[FloatingWindowControl] Current state: \(windowManager.state)")
64-
print("[FloatingWindowControl] Is visible: \(windowManager.state.isVisible)")
62+
FlareLog.debug("FloatingWindowControl Show/Hide button tapped")
63+
FlareLog.debug("FloatingWindowControl Current state: \(windowManager.state)")
64+
FlareLog.debug("FloatingWindowControl Is visible: \(windowManager.state.isVisible)")
6565
}
6666

6767
if windowManager.state.isVisible {
6868
if PerformanceConfig.isVerboseLoggingEnabled {
69-
print("[FloatingWindowControl] 👁️ Hiding window")
69+
FlareLog.debug("FloatingWindowControl Hiding window")
7070
}
7171
windowManager.hide()
7272
} else {
7373
if PerformanceConfig.isVerboseLoggingEnabled {
74-
print("[FloatingWindowControl] 👁️ Showing window")
75-
print("[FloatingWindowControl] Monitor is monitoring: \(monitor.isMonitoring)")
74+
FlareLog.debug("FloatingWindowControl Showing window")
75+
FlareLog.debug("FloatingWindowControl Monitor is monitoring: \(monitor.isMonitoring)")
7676
}
7777

7878
if !monitor.isMonitoring {
7979
if PerformanceConfig.isVerboseLoggingEnabled {
80-
print("[FloatingWindowControl] 🚀 Starting monitoring")
80+
FlareLog.debug("FloatingWindowControl Starting monitoring")
8181
}
8282
monitor.startMonitoring()
8383
}
8484

8585
if PerformanceConfig.isVerboseLoggingEnabled {
86-
print("[FloatingWindowControl] 📱 Calling windowManager.show()")
86+
FlareLog.debug("FloatingWindowControl Calling windowManager.show()")
8787
}
8888
windowManager.show()
8989

9090
if PerformanceConfig.isVerboseLoggingEnabled {
91-
print("[FloatingWindowControl] ✅ windowManager.show() completed")
92-
print("[FloatingWindowControl] New state: \(windowManager.state)")
91+
FlareLog.debug("FloatingWindowControl windowManager.show() completed")
92+
FlareLog.debug("FloatingWindowControl New state: \(windowManager.state)")
9393
}
9494
}
9595
}) {

iosApp/iosApp/Common/Performance/FrameRateOptimizer.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ class FrameRateOptimizer {
2020

2121
func startOptimization() {
2222
guard !isOptimizationActive else {
23-
print("🚀 [FrameRateOptimizer] Already optimized")
23+
FlareLog.debug("FrameRateOptimizer Already optimized")
2424
return
2525
}
26-
26+
2727
setupFrameRateOptimization()
2828
isOptimizationActive = true
29-
29+
3030
#if DEBUG
31-
print("🚀 [FrameRateOptimizer] 120fps optimization started")
32-
print("📱 [FrameRateOptimizer] Device max refresh rate: \(UIScreen.main.maximumFramesPerSecond)fps")
33-
print("🔧 [FrameRateOptimizer] ProMotion support: \(UIScreen.main.maximumFramesPerSecond > 60 ? "✅ YES" : "❌ NO")")
31+
FlareLog.performance("FrameRateOptimizer 120fps optimization started")
32+
FlareLog.performance("FrameRateOptimizer Device max refresh rate: \(UIScreen.main.maximumFramesPerSecond)fps")
33+
FlareLog.performance("FrameRateOptimizer ProMotion support: \(UIScreen.main.maximumFramesPerSecond > 60 ? "✅ YES" : "❌ NO")")
3434
#endif
3535
}
3636

@@ -58,14 +58,14 @@ class FrameRateOptimizer {
5858
)
5959

6060
#if DEBUG
61-
print("🔧 [FrameRateOptimizer] Configured preferredFrameRateRange: 60-\(maxFrameRate)fps")
61+
FlareLog.performance("FrameRateOptimizer Configured preferredFrameRateRange: 60-\(maxFrameRate)fps")
6262
#endif
6363
} else {
6464
// iOS 15以下版本的兼容处理
6565
frameRateDisplayLink?.preferredFramesPerSecond = UIScreen.main.maximumFramesPerSecond
6666

6767
#if DEBUG
68-
print("🔧 [FrameRateOptimizer] Configured preferredFramesPerSecond: \(UIScreen.main.maximumFramesPerSecond)fps")
68+
FlareLog.performance("FrameRateOptimizer Configured preferredFramesPerSecond: \(UIScreen.main.maximumFramesPerSecond)fps")
6969
#endif
7070
}
7171

@@ -99,8 +99,8 @@ extension FrameRateOptimizer {
9999

100100
#if DEBUG
101101
let info = FrameRateOptimizer.shared.getDeviceFrameRateInfo()
102-
print("""
103-
📱 [FrameRateOptimizer] Device Configuration:
102+
FlareLog.performance("""
103+
FrameRateOptimizer Device Configuration:
104104
- Max FPS: \(info.maxFPS)
105105
- ProMotion: \(info.isProMotionSupported ? "" : "")
106106
- Platform: \(info.isSimulator ? "🖥️ Simulator" : "📱 Device")

0 commit comments

Comments
 (0)