XcodeColors Is Dead :(
So it looks like Apple’s killed XcodeColors</a> in Xcode8 (as well as virtually every other plugin), breaking the ability to have coloured log messages in the console. This is a huge letdown as colors helped to differentiate between different log levels when using CocoaLumberjack!
Browing through an issue on Github gave me an idea to use emojis as a temporary solution:
Wasn’t a huge fan of the lack of colour variation but I think I’m happy with this set:
This is what my custom formatter looks like now:
- (NSString*)formatLogMessage:(DDLogMessage *)logMessage
{
NSString *path = logMessage->_file;
NSString *fileName = [path lastPathComponent];
NSString *dateAndTime = [self stringFromDate:(logMessage->_timestamp)];
NSString *logLevel;
switch (logMessage->_flag) {
case DDLogFlagError : logLevel = @""📕""; break;
case DDLogFlagWarning : logLevel = @""📒""; break;
case DDLogFlagInfo : logLevel = @""📘""; break;
case DDLogFlagDebug : logLevel = @""📗""; break;
default : logLevel = @""📓""; break;
}
return [NSString stringWithFormat:@""%@%@%@ %@:%lu %@"", logLevel, dateAndTime, logMessage->_function, fileName, (unsigned long)logMessage->_line, logMessage->_message];
}
While not nearly as good as what we had before there is one advantage: since emojis are being used it means that they’ll copy over when the text is copied.
Written on October 5, 2016