From b389c2c7f7478deebeb1a038d31c5aa937b2ec21 Mon Sep 17 00:00:00 2001 From: Josef Zoller Date: Tue, 9 Oct 2018 23:29:03 +0200 Subject: [PATCH] Changed debug message file locations to StORMDebug.location --- Sources/Convenience.swift | 12 ++++++------ Sources/Delete.swift | 6 +++--- Sources/Insert.swift | 10 +++++----- Sources/MySQLConnect.swift | 4 ++-- Sources/MySQLStORM.swift | 14 +++++++------- Sources/SQL.swift | 4 ++-- Sources/Select.swift | 2 +- Sources/Update.swift | 4 ++-- Sources/Upsert.swift | 2 +- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Sources/Convenience.swift b/Sources/Convenience.swift index 8e773a2..b2d5374 100644 --- a/Sources/Convenience.swift +++ b/Sources/Convenience.swift @@ -20,7 +20,7 @@ extension MySQLStORM { do { try exec(deleteSQL(self.table(), idName: idname), params: [String(describing: idval)]) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error } @@ -32,7 +32,7 @@ extension MySQLStORM { do { try exec(deleteSQL(self.table(), idName: idname), params: [String(describing: id)]) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error } @@ -44,7 +44,7 @@ extension MySQLStORM { do { try select(whereclause: "\(idname) = ?", params: [String(describing: id)], orderby: []) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error } @@ -56,7 +56,7 @@ extension MySQLStORM { do { try select(whereclause: "\(idname) = ?", params: [String(describing: idval)], orderby: []) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error } @@ -76,7 +76,7 @@ extension MySQLStORM { do { try select(whereclause: set.joined(separator: " AND "), params: paramsString, orderby: [idname]) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error } @@ -97,7 +97,7 @@ extension MySQLStORM { do { try select(whereclause: set.joined(separator: " AND "), params: paramsString, orderby: [idname]) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error } diff --git a/Sources/Delete.swift b/Sources/Delete.swift index 95d946b..8f2821f 100644 --- a/Sources/Delete.swift +++ b/Sources/Delete.swift @@ -23,7 +23,7 @@ extension MySQLStORM { do { try exec(deleteSQL(self.table(), idName: idName), params: [String(id)]) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error } @@ -36,7 +36,7 @@ extension MySQLStORM { do { try exec(deleteSQL(self.table(), idName: idName), params: [id]) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error } @@ -49,7 +49,7 @@ extension MySQLStORM { do { try exec(deleteSQL(self.table(), idName: idName), params: [id.string]) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error } diff --git a/Sources/Insert.swift b/Sources/Insert.swift index a69f776..0d63748 100644 --- a/Sources/Insert.swift +++ b/Sources/Insert.swift @@ -25,7 +25,7 @@ extension MySQLStORM { do { return try insert(cols: keys, params: vals) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) throw StORMError.error("\(error)") } } @@ -43,7 +43,7 @@ extension MySQLStORM { do { return try insert(cols: keys, params: vals) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) throw StORMError.error("\(error)") } } @@ -56,7 +56,7 @@ extension MySQLStORM { do { return try insert(cols: cols, params: params, idcolumn: idname) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) throw StORMError.error("\(error)") } } @@ -72,13 +72,13 @@ extension MySQLStORM { } let str = "INSERT INTO \(self.table()) (\(cols.joined(separator: ","))) VALUES(\(substString.joined(separator: ",")))" - if StORMdebug { LogFile.info("insert statement: \(str), params: \(paramString)", logFile: "./StORMlog.txt") } + if StORMDebug.active { LogFile.info("insert statement: \(str), params: \(paramString)", logFile: StORMDebug.location) } do { _ = try exec(str, params: paramString, isInsert: true) return results.insertedID } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error } diff --git a/Sources/MySQLConnect.swift b/Sources/MySQLConnect.swift index 88bf94e..3751e4a 100644 --- a/Sources/MySQLConnect.swift +++ b/Sources/MySQLConnect.swift @@ -54,7 +54,7 @@ open class MySQLConnect: StORMConnect { guard status else { // verify connection success - LogFile.error("MySQL network connection error: \(server.errorMessage())", logFile: "./StORMlog.txt") + LogFile.error("MySQL network connection error: \(server.errorMessage())", logFile: StORMDebug.location) resultCode = .error(server.errorMessage()) return } @@ -69,7 +69,7 @@ open class MySQLConnect: StORMConnect { guard status else { // verify connection success - LogFile.error("MySQL socket connection error: \(server.errorMessage())", logFile: "./StORMlog.txt") + LogFile.error("MySQL socket connection error: \(server.errorMessage())", logFile: StORMDebug.location) resultCode = .error(server.errorMessage()) return } diff --git a/Sources/MySQLStORM.swift b/Sources/MySQLStORM.swift index a5b501f..1c50118 100644 --- a/Sources/MySQLStORM.swift +++ b/Sources/MySQLStORM.swift @@ -63,7 +63,7 @@ open class MySQLStORM: StORM, StORMProtocol { } private func printDebug(_ statement: String, _ params: [String]) { - if StORMdebug { LogFile.debug("StORM Debug: \(statement) : \(params.joined(separator: ", "))", logFile: "./StORMlog.txt") } + if StORMDebug.active { LogFile.debug("StORM Debug: \(statement) : \(params.joined(separator: ", "))", logFile: StORMDebug.location) } } // Internal function which executes statements, with parameter binding @@ -230,7 +230,7 @@ open class MySQLStORM: StORM, StORMProtocol { try update(data: asData(1), idName: idname, idValue: idval) } } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) throw StORMError.error("\(error)") } } @@ -250,7 +250,7 @@ open class MySQLStORM: StORM, StORMProtocol { try update(data: asData(1), idName: idname, idValue: idval) } } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) throw StORMError.error("\(error)") } } @@ -260,7 +260,7 @@ open class MySQLStORM: StORM, StORMProtocol { do { try insert(asData()) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) throw StORMError.error("\(error)") } } @@ -282,7 +282,7 @@ open class MySQLStORM: StORM, StORMProtocol { /// - Parameter str: create statement /// - Parameter defaultTypes: by default it is true so MySQLStORM decides for the type conversion. To be able to provide your own, you need to override the `subscript(key: String) -> String` open func setup(_ str: String = "", _ useDefaults: Bool? = true) throws { - LogFile.info("Running setup: \(table())", logFile: "./StORMlog.txt") + LogFile.info("Running setup: \(table())", logFile: StORMDebug.location) var createStatement = str if str.count == 0 { var opt = [String]() @@ -326,12 +326,12 @@ open class MySQLStORM: StORM, StORMProtocol { let keyComponent = ", PRIMARY KEY (`\(keyName)`)" createStatement = "CREATE TABLE IF NOT EXISTS \(table()) (\(opt.joined(separator: ", "))\(keyComponent));" - if StORMdebug { LogFile.info("createStatement: \(createStatement)", logFile: "./StORMlog.txt") } + if StORMDebug.active { LogFile.info("createStatement: \(createStatement)", logFile: StORMDebug.location) } } do { try sql(createStatement, params: []) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) throw StORMError.error("\(error)") } } diff --git a/Sources/SQL.swift b/Sources/SQL.swift index 91efa00..c00a57d 100644 --- a/Sources/SQL.swift +++ b/Sources/SQL.swift @@ -19,7 +19,7 @@ extension MySQLStORM { try exec(statement, params: params) } catch { if !MySQLConnector.quiet { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) } self.error = StORMError.error("\(error)") throw error @@ -34,7 +34,7 @@ extension MySQLStORM { return try execRows(statement, params: params) } catch { if !MySQLConnector.quiet { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) } self.error = StORMError.error("\(error)") throw error diff --git a/Sources/Select.swift b/Sources/Select.swift index 769a012..2bc6ea7 100644 --- a/Sources/Select.swift +++ b/Sources/Select.swift @@ -144,7 +144,7 @@ extension MySQLStORM { //return results } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error } diff --git a/Sources/Update.swift b/Sources/Update.swift index 878624c..a9909ca 100644 --- a/Sources/Update.swift +++ b/Sources/Update.swift @@ -31,7 +31,7 @@ extension MySQLStORM { do { try exec(str, params: paramsString) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error } @@ -54,7 +54,7 @@ extension MySQLStORM { do { return try update(cols: keys, params: vals, idName: idName, idValue: idValue) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) throw StORMError.error("\(error)") } } diff --git a/Sources/Upsert.swift b/Sources/Upsert.swift index a513934..7622771 100644 --- a/Sources/Upsert.swift +++ b/Sources/Upsert.swift @@ -43,7 +43,7 @@ extension MySQLStORM { do { try exec(str, params: paramsString) } catch { - LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt") + LogFile.error("Error msg: \(error)", logFile: StORMDebug.location) self.error = StORMError.error("\(error)") throw error }