Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ability to change log file location #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Sources/Convenience.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension SQLiteStORM {
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
}
Expand All @@ -31,7 +31,7 @@ extension SQLiteStORM {
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
}
Expand All @@ -43,7 +43,7 @@ extension SQLiteStORM {
do {
try select(whereclause: "\(idname) = :1", 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
}
Expand All @@ -55,7 +55,7 @@ extension SQLiteStORM {
do {
try select(whereclause: "\(idname) = :1", 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
}
Expand All @@ -76,7 +76,7 @@ extension SQLiteStORM {
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
}
Expand All @@ -99,7 +99,7 @@ extension SQLiteStORM {
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
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Delete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension SQLiteStORM {
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
}
Expand All @@ -36,7 +36,7 @@ extension SQLiteStORM {
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
}
Expand All @@ -49,7 +49,7 @@ extension SQLiteStORM {
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
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Insert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension SQLiteStORM {
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)")
}
}
Expand All @@ -44,7 +44,7 @@ extension SQLiteStORM {
let x = try execReturnID(str, params: paramString)
return x
} catch {
LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt")
LogFile.error("Error msg: \(error)", logFile: StORMDebug.location)
self.error = StORMError.error("\(error)")
throw error
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/SQL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension SQLiteStORM {
do {
try execStatement(statement)
} catch {
LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt")
LogFile.error("Error msg: \(error)", logFile: StORMDebug.location)
self.error = StORMError.error("\(error)")
throw error
}
Expand All @@ -32,7 +32,7 @@ extension SQLiteStORM {
do {
return try exec(statement, params: params)
} catch {
LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt")
LogFile.error("Error msg: \(error)", logFile: StORMDebug.location)
self.error = StORMError.error("\(error)")
throw error
}
Expand All @@ -45,7 +45,7 @@ extension SQLiteStORM {
do {
return try execReturnID(statement, params: params)
} catch {
LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt")
LogFile.error("Error msg: \(error)", logFile: StORMDebug.location)
self.error = StORMError.error("\(error)")
throw error
}
Expand All @@ -58,7 +58,7 @@ extension SQLiteStORM {
do {
return try execRows(statement, params: params)
} catch {
LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt")
LogFile.error("Error msg: \(error)", logFile: StORMDebug.location)
self.error = StORMError.error("\(error)")
throw error
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SQLiteConnect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ open class SQLiteConnect: StORMConnect {
let db = try SQLite(self.database)
return db
} catch {
LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt")
LogFile.error("Error msg: \(error)", logFile: StORMDebug.location)
throw StORMError.error("\(error)")
}
}
Expand Down
14 changes: 7 additions & 7 deletions Sources/SQLiteStORM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ open class SQLiteStORM: StORM {
}

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
Expand Down Expand Up @@ -218,7 +218,7 @@ open class SQLiteStORM: StORM {
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)")
}
return 0
Expand All @@ -239,7 +239,7 @@ open class SQLiteStORM: StORM {
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)")
}
}
Expand All @@ -249,7 +249,7 @@ open class SQLiteStORM: StORM {
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)")
}
}
Expand All @@ -263,7 +263,7 @@ open class SQLiteStORM: StORM {
/// Requires the connection to be configured, as well as a valid "table" property to have been set in the class
/// Creates the table by inspecting the object. Columns will be created that relate to the assigned type of the property. Properties beginning with an underscore or "internal_" will be ignored.
open func setup() throws {
LogFile.info("Running setup: \(table())", logFile: "./StORMlog.txt")
LogFile.info("Running setup: \(table())", logFile: StORMDebug.location)
var opt = [String]()
for child in Mirror(reflecting: self).children {
guard let key = child.label else {
Expand Down Expand Up @@ -292,12 +292,12 @@ open class SQLiteStORM: StORM {
}
}
let createStatement = "CREATE TABLE IF NOT EXISTS \(table()) (\(opt.joined(separator: ", ")))"
if StORMdebug { LogFile.info("createStatement: \(createStatement)", logFile: "./StORMlog.txt") }
if StORMDebug.active { LogFile.info("createStatement: \(createStatement)", logFile: StORMDebug.location) }

do {
try sqlExec(createStatement)
} catch {
LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt")
LogFile.error("Error msg: \(error)", logFile: StORMDebug.location)
throw StORMError.error("\(error)")
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Select.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ extension SQLiteStORM {
if results.cursorData.totalRecords == 1 { makeRow() }

} catch {
LogFile.error("Error msg: \(error)", logFile: "./StORMlog.txt")
LogFile.error("Error msg: \(error)", logFile: StORMDebug.location)
self.errorMsg = "\(error)"
throw error
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Update.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension SQLiteStORM {
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
}
Expand All @@ -54,7 +54,7 @@ extension SQLiteStORM {
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)")
}
}
Expand Down