DnsUpdater/Sources/App/Model/AppState.swift

31 lines
828 B
Swift
Raw Normal View History

2024-11-15 10:46:29 +01:00
import Foundation
struct AppState: Codable {
var date: Date
var state: GlobalState
var domainStates: [String : DomainState]
}
extension AppState: Equatable {
}
extension AppState {
func print(to log: Log) {
log.debug("AppState \(date.formatted()): \(state)")
for (domain, state) in domainStates {
log.debug(" \(domain): \(state.lastResult)")
if state.currentWaitPeriod > 0 || state.serverErrorCount > 0 || state.clientErrorCount > 0 {
log.debug(" Last update: \(state.date.formatted()), wait time: \(state.currentWaitPeriod) s, \(state.serverErrorCount)/\(state.clientErrorCount) errors")
}
if !state.addresses.isEmpty {
log.debug(" IPs: \(state.addressList)")
}
}
}
}