//
//  HomeAllFunctionsDiagnostics.swift
//  suixinkan
//
//  Created by Codex on 2026/6/30.
//

import Foundation
import os

/// 「全部功能」页诊断日志，便于与 Android `AllFunctionsViewModel` 输出对比。
enum HomeAllFunctionsDiagnostics {
    private static let logger = Logger(subsystem: "com.yuanzhixiang.suixinkan", category: "HomeAllFunctions")

    /// 记录全部功能页的分区菜单 URI 列表。
    static func log(snapshot: HomeAllFunctionsSnapshot) {
        #if DEBUG
        log(step: "allFunctions", uris: snapshot.allFunctions.map(\.uri))
        log(step: "commonFunctions", uris: snapshot.commonFunctions.map(\.uri))
        log(step: "moreFunctions", uris: snapshot.moreFunctions.map(\.uri))
        #endif
    }

    /// 记录单步 URI 列表。
    private static func log(step: String, uris: [String]) {
        let payload = "count=\(uris.count) uris=\(HomeCommonMenuDiagnostics.formatURIList(uris))"
        logger.debug("step=\(step, privacy: .public) \(payload, privacy: .public)")
    }
}
