FCLogger 是一个 DDAbstractLogger 实现,允许在应用内部显示所有 CocoaLumberjack 日志,支持自定义颜色(如 XCodeColors)。
将 pod 添加到您的 podfile
pod 'FCLogger'
将文件导入到您的项目中
FCLogger.h
FCLogger.m
请查看提供的 FCLoggerSample 应用。
#import <FCLogger/FCLogger.h>
// create the FC logger
self.fcLogger = [[FCLogger alloc] init];
//assign a standard UITextView
self.fcLogger.textView = self.textView;
//enable auto scroll
self.fcLogger.autoScrollsToBottom = YES;
//enable colors support
self.fcLogger.colorsEnabled = YES;
//add logger to CocoaLumberjack
[DDLog addLogger:self.fcLogger];
//set custom color for specific log flag
[self.fcLogger setLogColor:[UIColor blueColor] forFlag:DDLogFlagDebug];
DDLogDebug(@"Test debug log");
DDLogError(@"Test error log");