31 lines
828 B
Swift
31 lines
828 B
Swift
|
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)")
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|