Skip to content

Instantly share code, notes, and snippets.

@RustyKnight
Created February 5, 2022 23:23
Show Gist options
  • Save RustyKnight/f343c8f2cb45fbfe4c17f690a3324424 to your computer and use it in GitHub Desktop.
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
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