Skip to content

Instantly share code, notes, and snippets.

@sahara-ooga
Created April 20, 2022 16:29
Show Gist options
  • Save sahara-ooga/d7113a78c2039888c6cbe59a1da856bf to your computer and use it in GitHub Desktop.
Save sahara-ooga/d7113a78c2039888c6cbe59a1da856bf to your computer and use it in GitHub Desktop.

Definition

        func customPrint(line: Int = #line, file: String = #file, _ target: Any) {
            Pretty.splatPrint(
                    label: nil,
                    targets: ["file", file],
                    separator: " : ",
                    option: Pretty.Option(colored: true)
            )
            Pretty.splatPrint(
                    label: nil,
                    targets: ["line", line],
                    separator: " : ",
                    option: Pretty.Option(colored: true)
            )
            Pretty.print(target, option: Pretty.Option(colored: true))
        }

Call site

        let owner = Owner(name: "Nanachi", age: 20, address: "4th layer in Abyss")
       customPrint(owner)

       let owner2 = Owner(name: "aaaa", age: 40, address: "bbbbb")
       customPrint(owner2)

Output

 2022-04-21 1 29 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment