LogKit
基于 CocoaLumberjack 和 ZipArchive 的日志框架
特性
- 易于测试和收集难以复现的问题,我们可以发送日志至邮箱(无需 Xcode)
- 在 Xcode 控制台或 iPhone 中根据日志等级输出带有相应颜色的不同日志信息(Xcode 控制台需要 XcodeColors 插件)
预览
GIF |
---|
![]() |
辅助按钮 | 调试视图 | 日志邮件 | Xcode 控制台 |
---|---|---|---|
![]() |
![]() |
![]() |
![]() |
使用方法
DLogTrace(); // ouput current function
DLogVerbose(@""); // ouput verbose level log message
DLogDebug(@""); // ouput debug level log message
DLogInfo(@""); // ouput info level log message
DLogWarn(@""); // ouput warn level log message
DLogError(@""); // ouput error level log message
配置
项目 AppDelegate.m 中的配置设置
// #import 'LogKit.h'
// #import <LogKit.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[LogKit addTTYLogger]; // Configure and add a DDTTYLogger (Apple System Log and Xcode console)
[LogKit addFileLogger]; // Send the log to the file (default for non debug builds),requied this method if you want send log files to mail
#ifdef DEBUG
[LogKit addDashboardLogger]; // Configure and add a recorder with console logs
#endif
[LogKit setDefaultMailAddress:@[@"[email protected]"]]; // Sets the mailbox collection that receives log files (default is empty)
[LogKit setDefaultLogPassword:@"101001"]; // Set the password for the log file (default is empty)
return YES;
}
安装
source 'https://github.com/CocoaPods/Specs.git'
pod 'CocoaLogKit'
许可协议
CocoaLogKit
使用 MIT 许可协议