Created
November 7, 2015 17:22
-
-
Save kristopherjohnson/13a4e3781818d8cf66b3 to your computer and use it in GitHub Desktop.
Simple logging functions for Swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| func logDebug(message: String, | |
| function: String = __FUNCTION__, file: String = __FILE__, line: Int = __LINE__) | |
| { | |
| #if DEBUG | |
| let filename = (file as NSString).lastPathComponent | |
| let msg = "DEBUG: \(message) [\(function) \(filename):\(line)]" | |
| NSLog("%@", msg); | |
| #endif | |
| } | |
| func logError(message: String, | |
| function: String = __FUNCTION__, file: String = __FILE__, line: Int = __LINE__) | |
| { | |
| let filename = (file as NSString).lastPathComponent | |
| let msg = "ERROR: \(message) [\(function) \(filename):\(line)]" | |
| NSLog("%@", msg); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output for
logError("unable to find UserDefaults.plist")