3

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?

Senseful
  • 86,719
  • 67
  • 308
  • 465

1 Answers1

3

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

Senseful
  • 86,719
  • 67
  • 308
  • 465