diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2018-05-15 10:19:10 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2018-05-15 10:19:10 -0400 |
commit | 10674f7858520130b760bcad44c00ee0b6412de8 (patch) | |
tree | fa7873a525904af6785c10c8305b2890f951a011 | |
parent | cc5eae8907aaab89a9634c259be62382b145a5ac (diff) | |
download | sdl_ios-bugfix/issue_960_logging_custom_modules_swift.tar.gz |
Fix swift logging of file names correct, fixing modules in swiftbugfix/issue_960_logging_custom_modules_swift
-rw-r--r-- | SmartDeviceLinkSwift/SDLLog.swift | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/SmartDeviceLinkSwift/SDLLog.swift b/SmartDeviceLinkSwift/SDLLog.swift index d2391a0e4..c7bc4b070 100644 --- a/SmartDeviceLinkSwift/SDLLog.swift +++ b/SmartDeviceLinkSwift/SDLLog.swift @@ -27,7 +27,7 @@ public class SDLLog { /// - function: The function the log is coming from, you should probably leave this as the default. /// - line: The line the log is coming from, you should probably leave this as the default. public class func v(_ message: @autoclosure () -> Any, _ file: String = #file, _ function: String = #function, _ line: Int = #line) { - SDLLogManager.log(with: .verbose, timestamp: Date(), file: file, functionName: function, line: line, queue: logQueue(), message: "\(message())") + SDLLogManager.log(with: .verbose, timestamp: Date(), file: stripFileName(file), functionName: function, line: line, queue: logQueue(), message: "\(message())") } /// Log a debug message through SDL's custom logging framework. @@ -38,7 +38,7 @@ public class SDLLog { /// - function: The function the log is coming from, you should probably leave this as the default. /// - line: The line the log is coming from, you should probably leave this as the default. public class func d(_ message: @autoclosure () -> Any, _ file: String = #file, _ function: String = #function, _ line: Int = #line) { - SDLLogManager.log(with: .debug, timestamp: Date(), file: file, functionName: function, line: line, queue: logQueue(), message: "\(message())") + SDLLogManager.log(with: .debug, timestamp: Date(), file: stripFileName(file), functionName: function, line: line, queue: logQueue(), message: "\(message())") } /// Log a warning message through SDL's custom logging framework. @@ -49,7 +49,7 @@ public class SDLLog { /// - function: The function the log is coming from, you should probably leave this as the default. /// - line: The line the log is coming from, you should probably leave this as the default. public class func w(_ message: @autoclosure () -> Any, _ file: String = #file, _ function: String = #function, _ line: Int = #line) { - SDLLogManager.log(with: .warning, timestamp: Date(), file: file, functionName: function, line: line, queue: logQueue(), message: "\(message())") + SDLLogManager.log(with: .warning, timestamp: Date(), file: stripFileName(file), functionName: function, line: line, queue: logQueue(), message: "\(message())") } /// Log an error message through SDL's custom logging framework. @@ -60,7 +60,12 @@ public class SDLLog { /// - function: The function the log is coming from, you should probably leave this as the default. /// - line: The line the log is coming from, you should probably leave this as the default. public class func e(_ message: @autoclosure () -> Any, _ file: String = #file, _ function: String = #function, _ line: Int = #line) { - SDLLogManager.log(with: .error, timestamp: Date(), file: file, functionName: function, line: line, queue: logQueue(), message: "\(message())") + SDLLogManager.log(with: .error, timestamp: Date(), file: stripFileName(file), functionName: function, line: line, queue: logQueue(), message: "\(message())") + } + + class func stripFileName(_ file: String) -> String { + let url = URL(fileURLWithPath: file) + return url.deletingPathExtension().lastPathComponent } } @@ -72,7 +77,7 @@ public class SDLLog { /// - function: The function the log is coming from, you should probably leave this as the default. /// - line: The line the log is coming from, you should probably leave this as the default. public func SDLV(_ message: @autoclosure () -> Any, _ file: String = #file, _ function: String = #function, _ line: Int = #line) { - SDLLogManager.log(with: .verbose, timestamp: Date(), file: file, functionName: function, line: line, queue: logQueue(), message: "\(message())") + SDLLogManager.log(with: .verbose, timestamp: Date(), file: SDLLog.stripFileName(file), functionName: function, line: line, queue: logQueue(), message: "\(message())") } /// Log a debug message through SDL's custom logging framework. @@ -83,7 +88,7 @@ public func SDLV(_ message: @autoclosure () -> Any, _ file: String = #file, _ fu /// - function: The function the log is coming from, you should probably leave this as the default. /// - line: The line the log is coming from, you should probably leave this as the default. public func SDLD(_ message: @autoclosure () -> Any, _ file: String = #file, _ function: String = #function, _ line: Int = #line) { - SDLLogManager.log(with: .debug, timestamp: Date(), file: file, functionName: function, line: line, queue: logQueue(), message: "\(message())") + SDLLogManager.log(with: .debug, timestamp: Date(), file: SDLLog.stripFileName(file), functionName: function, line: line, queue: logQueue(), message: "\(message())") } /// Log a warning message through SDL's custom logging framework. @@ -94,7 +99,7 @@ public func SDLD(_ message: @autoclosure () -> Any, _ file: String = #file, _ fu /// - function: The function the log is coming from, you should probably leave this as the default. /// - line: The line the log is coming from, you should probably leave this as the default. public func SDLW(_ message: @autoclosure () -> Any, _ file: String = #file, _ function: String = #function, _ line: Int = #line) { - SDLLogManager.log(with: .warning, timestamp: Date(), file: file, functionName: function, line: line, queue: logQueue(), message: "\(message())") + SDLLogManager.log(with: .warning, timestamp: Date(), file: SDLLog.stripFileName(file), functionName: function, line: line, queue: logQueue(), message: "\(message())") } /// Log an error message through SDL's custom logging framework. @@ -105,7 +110,7 @@ public func SDLW(_ message: @autoclosure () -> Any, _ file: String = #file, _ fu /// - function: The function the log is coming from, you should probably leave this as the default. /// - line: The line the log is coming from, you should probably leave this as the default. public func SDLE(_ message: @autoclosure () -> Any, _ file: String = #file, _ function: String = #function, _ line: Int = #line) { - SDLLogManager.log(with: .error, timestamp: Date(), file: file, functionName: function, line: line, queue: logQueue(), message: "\(message())") + SDLLogManager.log(with: .error, timestamp: Date(), file: SDLLog.stripFileName(file), functionName: function, line: line, queue: logQueue(), message: "\(message())") } private func logQueue() -> String { |