diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2017-03-09 11:27:55 -0500 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2017-03-09 11:27:55 -0500 |
commit | 584f5ef9e3d2344e98fa034af3712a4be9c03399 (patch) | |
tree | db9e0b88177d79e80927c34f559492b3730c395c /SmartDeviceLinkSwift | |
parent | 0a8a5724af8293e99f0218c9fa4b33f7d4fb3ee9 (diff) | |
download | sdl_ios-584f5ef9e3d2344e98fa034af3712a4be9c03399.tar.gz |
Update podspec with a swift subspec
Diffstat (limited to 'SmartDeviceLinkSwift')
-rw-r--r-- | SmartDeviceLinkSwift/SDLLog.swift | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/SmartDeviceLinkSwift/SDLLog.swift b/SmartDeviceLinkSwift/SDLLog.swift new file mode 100644 index 000000000..5121d39f2 --- /dev/null +++ b/SmartDeviceLinkSwift/SDLLog.swift @@ -0,0 +1,109 @@ +// +// SDLLog.swift +// SmartDeviceLink-iOS +// +// Created by Joel Fischer on 3/2/17. +// Copyright © 2017 smartdevicelink. All rights reserved. +// + +import Foundation + +import SmartDeviceLink + + +/// You may use this class or the below functions for convenience logging in Swift 3 projects. +/// It would be used like so: +/// +/// ``` +/// let log = SDLLog.self +/// log.e("Test something \(NSDate())") +/// ``` +public class SDLLog { + /// Log a verbose message through SDL's custom logging framework. + /// + /// - Parameters: + /// - message: The message to be logged. + /// - file: The file the log is coming from, you should probably leave this as the default. + /// - 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, file: file, functionName: function, line: line, message: "\(message())") + } + + /// Log a debug message through SDL's custom logging framework. + /// + /// - Parameters: + /// - message: The message to be logged. + /// - file: The file the log is coming from, you should probably leave this as the default. + /// - 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, file: file, functionName: function, line: line, message: "\(message())") + } + + /// Log a warning message through SDL's custom logging framework. + /// + /// - Parameters: + /// - message: The message to be logged. + /// - file: The file the log is coming from, you should probably leave this as the default. + /// - 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, file: file, functionName: function, line: line, message: "\(message())") + } + + /// Log an error message through SDL's custom logging framework. + /// + /// - Parameters: + /// - message: The message to be logged. + /// - file: The file the log is coming from, you should probably leave this as the default. + /// - 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, file: file, functionName: function, line: line, message: "\(message())") + } +} + +/// Log a verbose message through SDL's custom logging framework. +/// +/// - Parameters: +/// - message: The message to be logged. +/// - file: The file the log is coming from, you should probably leave this as the default. +/// - 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, file: file, functionName: function, line: line, message: "\(message())") +} + +/// Log a debug message through SDL's custom logging framework. +/// +/// - Parameters: +/// - message: The message to be logged. +/// - file: The file the log is coming from, you should probably leave this as the default. +/// - 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, file: file, functionName: function, line: line, message: "\(message())") +} + +/// Log a warning message through SDL's custom logging framework. +/// +/// - Parameters: +/// - message: The message to be logged. +/// - file: The file the log is coming from, you should probably leave this as the default. +/// - 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, file: file, functionName: function, line: line, message: "\(message())") +} + +/// Log an error message through SDL's custom logging framework. +/// +/// - Parameters: +/// - message: The message to be logged. +/// - file: The file the log is coming from, you should probably leave this as the default. +/// - 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, file: file, functionName: function, line: line, message: "\(message())") +} |