Last active
September 2, 2021 07:25
-
-
Save cbess/8fa7b9e2330a07020541 to your computer and use it in GitHub Desktop.
Simple Logger class in Swift 4.x
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 | |
/// Represents the Log facilities | |
struct Log { | |
/// Prints in debug only | |
static func debug(_ msg: String, line: Int = #line, fileName: String = #file, funcName: String = #function) { | |
#if DEBUG | |
let fname = (fileName as NSString).lastPathComponent | |
print("[\(fname) \(funcName):\(line)]", msg) | |
#endif | |
} | |
/// Prints an error message in debug only | |
static func error(_ msg: String, line: Int = #line, fileName: String = #file, funcName: String = #function) { | |
debug("ERROR: \(msg)!!", line: line, fileName: fileName, funcName: funcName) | |
} | |
/// Prints the debug mark for the line | |
static func mark(line: Int = #line, fileName: String = #file, funcName: String = #function) { | |
debug("called", line: line, fileName: fileName, funcName: funcName) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment