Logger: Convert do-catch to try?

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander
2019-01-28 17:50:48 +05:30
parent b0bb2e993a
commit acecc70397
+2 -3
View File
@@ -41,12 +41,11 @@ public class Logger {
os_log("Unable to determine log destination path. Log will not be saved to file.", log: OSLog.default, type: .error) os_log("Unable to determine log destination path. Log will not be saved to file.", log: OSLog.default, type: .error)
return return
} }
do { guard let logger = try? Logger(withFilePath: filePath) else {
try Logger.global = Logger(withFilePath: filePath)
} catch {
os_log("Unable to open log file for writing. Log will not be saved to file.", log: OSLog.default, type: .error) os_log("Unable to open log file for writing. Log will not be saved to file.", log: OSLog.default, type: .error)
return return
} }
Logger.global = logger
var appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown version" var appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown version"
if let appBuild = Bundle.main.infoDictionary?["CFBundleVersion"] as? String { if let appBuild = Bundle.main.infoDictionary?["CFBundleVersion"] as? String {
appVersion += " (\(appBuild))" appVersion += " (\(appBuild))"