Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I log a message in color to the Xcode 15 console?

Xcode 15 now displays log message in colors. For example, warnings seem to appear in yellow, while standard messages are in white.

I noticed that Swift Log (tutorial) has a color scheme as well:

enter image description here

Do I need to include Swift Log in my iOS app to output messages in color, or is there a built-in method to do so?

like image 910
Senseful Avatar asked Sep 20 '25 12:09

Senseful


1 Answers

You can use os.Logger to output different severity levels. No need to import a special library.

Note that unlike in the screenshot, Xcode only outputs 3 different colors:

logger.log("Log")
logger.trace("Trace")
logger.debug("Debug")
logger.info("Info")
logger.notice("Notice")
logger.warning("Warning")
logger.error("Error")
logger.critical("Critical")
logger.fault("Fault")

Example output in the Xcode Console:

enter image description here

like image 148
Senseful Avatar answered Sep 22 '25 04:09

Senseful