//
//  DebugLogger.swift
//  CheapRetouch
//
//  Debug logging utility for tracking user actions and app state.
//

import Foundation
import os.log
import CoreGraphics

enum DebugLogger: Sendable {
    private static let logger = Logger(subsystem: "com.cheapretouch", category: "debug")

    nonisolated static func log(_ message: String, file: String = #file, function: String = #function, line: Int = #line) {
        let fileName = (file as NSString).lastPathComponent
        let logMessage = "[\(fileName):\(line)] \(function) - \(message)"
        print("🔍 \(logMessage)")
    }

    nonisolated static func action(_ message: String) {
        print("👆 ACTION: \(message)")
    }

    nonisolated static func state(_ message: String) {
        print("📊 STATE: \(message)")
    }

    nonisolated static func error(_ message: String, error: Error? = nil) {
        if let error = error {
            print("❌ ERROR: \(message) - \(error.localizedDescription)")
        } else {
            print("❌ ERROR: \(message)")
        }
    }

    nonisolated static func processing(_ message: String) {
        print("⚙️ PROCESSING: \(message)")
    }

    nonisolated static func imageInfo(_ label: String, width: Int, height: Int) {
        print("🖼️ \(label): \(width)x\(height) pixels")
    }

    nonisolated static func imageInfo(_ label: String, image: CGImage?) {
        if let image = image {
            print("🖼️ \(label): \(image.width)x\(image.height) pixels")
        } else {
            print("🖼️ \(label): nil")
        }
    }
}
