print() to console log with color

Nowadays, Xcode debugging console doesn't support coloring.


Xcode doesn't support console coloring since Xcode 8.

But Since Xcode is fully unicode compatible, you can use emojis instead! for example you can use You can use ⚠️ for warning messages and 🛑 for error messages. (like the Xcode itself)

Or simply use these note books as a color:

📕: error message
📙: warning message
📗: ok status message
📘: action message
📓: canceled status message
📔: Or anything you like and want to recognize immediately by color

for example:

print("⚠️", "Touch is not disabled as expected")

🎁 Bones

Using this method will help you to find the logs in the source code as fast as ⚡️ by a simple eye scan:

Demo

And you can search for them 📱👁 to let the Xcode take you there. Take a look at this result comparison:

Custom emoji search

emoji search

vs

Word search

word search


Adding to @Mojtaba's answer, you can use this for automating logging:

enum LogType: String{
case error
case warning
case success
case action
case canceled
}


class Logger{

 static func log(_ logType:LogType,_ message:String){
        switch logType {
        case LogType.error:
            print("\n📕 Error: \(message)\n")
        case LogType.warning:
            print("\n📙 Warning: \(message)\n")
        case LogType.success:
            print("\n📗 Success: \(message)\n")
        case LogType.action:
            print("\n📘 Action: \(message)\n")
        case LogType.canceled:
            print("\n📓 Cancelled: \(message)\n")
        }
    }

}

You can use it this way:

Logger.log(.error, "Invalid Credit Information")