Created
February 5, 2022 23:23
-
-
Save RustyKnight/f343c8f2cb45fbfe4c17f690a3324424 to your computer and use it in GitHub Desktop.
A conceptual idea of to add additional logging information to the print statement
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
func print( | |
_ items: Any..., | |
separator: String = " ", | |
terminator: String = "\n", | |
file: StaticString = #file, | |
function: StaticString = #function, | |
line: UInt = #line, date: Date = Date() | |
) { | |
let components = file.description.components(separatedBy: "/") | |
if let name = components.last { | |
Swift.print("[\(name):\(function)@\(line)]: ", terminator: "") | |
} else { | |
Swift.print("[\(file):\(function)@\(line)]: ", terminator: "") | |
} | |
for item in items { | |
Swift.print(item, separator: separator, terminator: "") | |
} | |
Swift.print("", terminator: terminator) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment