🐛 Fix node connection & sync
This commit is contained in:
38
SwiftChainCore/Models/LogManager.swift
Normal file
38
SwiftChainCore/Models/LogManager.swift
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// LogManager.swift
|
||||
// SwiftChain
|
||||
//
|
||||
// Created by Victor on 05/05/2025.
|
||||
//
|
||||
|
||||
import os.log
|
||||
|
||||
public struct LogManager {
|
||||
public enum LogLevel: String {
|
||||
case info = "INFO"
|
||||
case success = "SUCCÈS"
|
||||
case warning = "ATTENTION"
|
||||
case error = "ERREUR"
|
||||
case network = "RÉSEAU"
|
||||
case blockchain = "BLOCKCHAIN"
|
||||
|
||||
var logType: OSLogType {
|
||||
switch self {
|
||||
case .info, .success: return .info
|
||||
case .warning: return .debug
|
||||
case .error: return .error
|
||||
case .network, .blockchain: return .default
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static let log = OSLog(subsystem: "com.votreapp.swiftchain", category: "blockchain")
|
||||
|
||||
public static func log(_ message: String, level: LogLevel) {
|
||||
os_log("%{public}@: %{public}@", log: log, type: level.logType, level.rawValue, message)
|
||||
|
||||
// Également afficher dans la console pour le CLI
|
||||
let timestamp = DateFormatter.localizedString(from: Date(), dateStyle: .none, timeStyle: .medium)
|
||||
print("[\(timestamp)] [\(level.rawValue)] \(message)")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user