Improve logging
This commit is contained in:
@ -42,7 +42,7 @@ extension Configuration {
|
||||
do {
|
||||
data = try Data(contentsOf: url)
|
||||
} catch {
|
||||
print("Failed to load configuration data from \(url.path): \(error)")
|
||||
log("Failed to load configuration data from \(url.path): \(error)")
|
||||
throw error
|
||||
}
|
||||
try self.init(data: data)
|
||||
@ -52,7 +52,7 @@ extension Configuration {
|
||||
do {
|
||||
self = try JSONDecoder().decode(Configuration.self, from: data)
|
||||
} catch {
|
||||
print("Failed to decode configuration: \(error)")
|
||||
log("Failed to decode configuration: \(error)")
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ final class SQLiteDatabase {
|
||||
let count = try await User.query(on: database).count()
|
||||
registeredPlayerCountMetric.update(count)
|
||||
} catch {
|
||||
print("Failed to update player count metric: \(error)")
|
||||
log("Failed to update player count metric: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ final class SQLiteDatabase {
|
||||
|
||||
private func sendEmail(name: PlayerName, email: String, token: String) {
|
||||
guard let mailData = mail else {
|
||||
print("Recovery email not set up")
|
||||
log("Recovery email not set up")
|
||||
return
|
||||
}
|
||||
let recipient = Mail.User(name: name, email: email)
|
||||
@ -154,7 +154,7 @@ final class SQLiteDatabase {
|
||||
|
||||
mailData.smtp.send(mail) { (error) in
|
||||
if let error = error {
|
||||
print("Failed to send recovery email to \(email): \(error)")
|
||||
log("Failed to send recovery email to \(email): \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ final class TableManagement {
|
||||
do {
|
||||
try await loadTables(from: database)
|
||||
} catch {
|
||||
print("Failed to load tables: \(error)")
|
||||
log("Failed to load tables: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -59,7 +59,7 @@ final class TableManagement {
|
||||
let id = table.id!
|
||||
self.tables[id] = WaitingTable(id: id, name: table.name, isPublic: table.isPublic, players: table.players)
|
||||
}
|
||||
print("\(tables.count) tables loaded")
|
||||
log("\(tables.count) tables loaded")
|
||||
logTableCount()
|
||||
logPlayingPlayerCount()
|
||||
logConnectedPlayerCount()
|
||||
@ -191,7 +191,7 @@ final class TableManagement {
|
||||
|
||||
func performAction(player: PlayerName, action: PlayerAction) -> PlayerActionResult {
|
||||
guard let table = currentTable(for: player) else {
|
||||
print("Player \(player) wants to \(action.id), but no table joined")
|
||||
log("Player \(player) wants to \(action.id), but no table joined")
|
||||
return .noTableJoined
|
||||
}
|
||||
let (result, newTable) = table.perform(action: action, forPlayer: player)
|
||||
@ -212,7 +212,7 @@ final class TableManagement {
|
||||
|
||||
func select(game: GameType, player: PlayerName) -> PlayerActionResult {
|
||||
guard let aTable = currentTable(for: player) else {
|
||||
print("Player \(player) wants to play \(game.rawValue), but no table joined")
|
||||
log("Player \(player) wants to play \(game.rawValue), but no table joined")
|
||||
return .noTableJoined
|
||||
}
|
||||
guard let table = aTable as? BiddingTable else {
|
||||
@ -223,7 +223,7 @@ final class TableManagement {
|
||||
return result
|
||||
}
|
||||
guard let newTable = newTable else {
|
||||
print("Game selected by \(player), but no playing table \(table.name) created")
|
||||
log("Game selected by \(player), but no playing table \(table.name) created")
|
||||
table.sendUpdateToAllPlayers()
|
||||
return result
|
||||
}
|
||||
|
Reference in New Issue
Block a user