From 137e87ad697ebad9470f5682b48a5de45b4a3da3 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 4 Nov 2018 15:56:05 +0100 Subject: [PATCH] Add description for generic ConnectionProfile --- Passepartout/Sources/Model/ConnectionProfile.swift | 8 +++++++- Passepartout/Sources/Model/ConnectionService.swift | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Passepartout/Sources/Model/ConnectionProfile.swift b/Passepartout/Sources/Model/ConnectionProfile.swift index a7e0e2ee..7ee7b148 100644 --- a/Passepartout/Sources/Model/ConnectionProfile.swift +++ b/Passepartout/Sources/Model/ConnectionProfile.swift @@ -33,7 +33,7 @@ enum Context: String, Codable { case host } -protocol ConnectionProfile: class, EndpointDataSource { +protocol ConnectionProfile: class, EndpointDataSource, CustomStringConvertible { var context: Context { get } var id: String { get } @@ -80,3 +80,9 @@ extension ConnectionProfile { keychain.removePassword(for: key) } } + +extension ConnectionProfile { + var description: String { + return "[\(context):\(id)]" + } +} diff --git a/Passepartout/Sources/Model/ConnectionService.swift b/Passepartout/Sources/Model/ConnectionService.swift index 75ef0529..790fc2b1 100644 --- a/Passepartout/Sources/Model/ConnectionService.swift +++ b/Passepartout/Sources/Model/ConnectionService.swift @@ -253,7 +253,7 @@ class ConnectionService: Codable { } else if let hostProfile = profile as? HostConnectionProfile { optData = try encoder.encode(hostProfile) } else if let placeholder = profile as? PlaceholderConnectionProfile { - log.debug("Skipped \(placeholder.context) '\(placeholder.id)'") + log.debug("Skipped placeholder \(placeholder)") } else { fatalError("Attempting to add an unhandled profile type: \(type(of: profile))") } @@ -261,9 +261,9 @@ class ConnectionService: Codable { return } try data.write(to: url) - log.debug("Serialized \(profile.context) profile '\(profile.id)'") + log.debug("Serialized profile \(profile)") } catch let e { - log.warning("Could not serialize \(profile.context) profile '\(profile.id)': \(e)") + log.warning("Could not serialize profile \(profile): \(e)") } }