Created
February 12, 2018 09:54
-
-
Save phynet/835165096157634ad375529377dfbb48 to your computer and use it in GitHub Desktop.
This file contains 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 | |
public struct Log | |
{ | |
public static var isEnabled = true | |
public static func debug(_ m: @autoclosure ()->String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) { | |
print(m(), file ?? "", f, line) | |
} | |
public static func error(_ m: @autoclosure ()->String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) { | |
_print("🚨 \(m())", file, f, line) | |
} | |
public static func warn(_ m: @autoclosure ()->String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) { | |
_print("⚠️ \(m())", file, f, line) | |
} | |
private static func _print(_ m: String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) { | |
if isEnabled { | |
print("\(file ?? "").\(f):\(line) -\(m)") | |
} | |
} | |
} | |
//Use: | |
Log.warn("\(error)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment