Skip to content
robbiehanson edited this page Jun 1, 2012 · 5 revisions

It's sometimes helpful to color-coordinate your log messages. For example, you may want your error messages to print in red so they stick out. This is possible with DDTTYLogger and XcodeColors.

Install XcodeColors

XcodeColors is a simple plugin for Xcode.

Full installation instructions can be found on the XcodeColors project page:
https://github.com/robbiehanson/XcodeColors

But here's a summary:

  • Download the plugin
  • Slap it into the Xcode Plug-ins directory
  • Restart Xcode

Enable Colors

All it takes is one extra line of code to enable colors in Lumberjack:

// Standard lumberjack initialization
[DDLog addLogger:[DDTTYLogger sharedInstance]];

// And we also enable colors
[[DDTTYLogger sharedInstance] setColorsEnabled:YES];

The default color scheme (if you don't customize it) is:

  • DDLogError : Prints in red
  • DDLogWarn : Prints in orange

However, you can fully customize the color schemes however you like!
In fact, you can customize the foreground and background colors.
And you can specify any RGB value you'd like.

// Let's customize our colors.
// DDLogInfo : Pink

#if TARGET_OS_IPHONE
UIColor *pink = [UIColor colorWithRed:(255/255.0) green:(58/255.0) blue:(159/255.0) alpha:1.0];
#else
NSColor *pink = [NSColor colorWithCalibratedRed:(255/255.0) green:(58/255.0) blue:(159/255.0) alpha:1.0];
#endif

[[DDTTYLogger sharedInstance] setForegroundColor:pink backgroundColor:nil forFlag:LOG_FLAG_INFO];

DDLogInfo(@"Warming up printer (post-customization)"); // Pink !

Clone this wiki locally