ZHLog
ZHLog是一个适用于iOS的打印工具,简单、快捷、方便!
特性
- 支持在调试模式下打印信息,在发布模式下不打印。
- 支持打印方法名和行号。
- 支持打印字节流。
- 支持将日志保存到本地,并可导出。
- 支持打印信息分类:警告、错误、调试信息、重要信息等。
- 日志按天保存,自动删除一个月前的日志。
- 支持手动清理日志。
- 支持二次开发。
要求
- iOS 7.0+
- ARC
使用方法
CocoaPods (推荐)
pod 'ZHLog'
开始使用
导入 <ZHLog/ZHShareLog.h>
示例用法
ZHLog(@"zhlog"); //The print information
ZHLogDebug(@"debug"); //debug the information, along with the name of the function, the line, and so on.
ZHLogInfo(@"Info");//Print the information, along with the name of the function, the line, and so on.
ZHLogImportant(@"Important");//Print important information, along with the name of the function, the line and so on.
ZHLogError(@"error");//Print the error message, along with the name of the function, the line, and so on.
ZHLogWarning(@"warning");//Print the warning message, along with the name of the function, the line, and so on.
ZHLogToFile(@"tofile", ZH_Log_Info);//Print the information, attach the name of the function, the line, and so on, and save it to the log.
[[ZHShareLog shareZHShareLog]printDebugInfo:@"Info" withLevel:ZH_Log_Error];//Print different types of information.
日志类型
typedef NS_ENUM(NSInteger,ZH_Log_Level)
{
ZH_Log_Error = 0,
ZH_Log_Info = 1,
ZH_Log_Warning = 2,
ZH_Log_Debug = 3,
ZH_Log_Important = 4,
ZH_Log_Verblose = 5,
};
清除日志
-(void)clearAllLogFile;
-(void)clearMonthAgoLogFile;
-(void)clearTodayLog;
打印二进制流数据
-(void)printLogWithBuffer:(Byte *)buffer andLength:(NSUInteger)length andLabel:(NSString *)flagStr;
Xcode终端显示截图
2018-04-21 11:42:03.260219+0800 ZHLog[75592:3057889] zhlog
2018-04-21 11:42:03.260355+0800 ZHLog[75592:3057889] ✅Debug: -[ViewController viewDidLoad] [Line 26] debug
2018-04-21 11:42:03.260438+0800 ZHLog[75592:3057889] 💧Info: -[ViewController viewDidLoad] [Line 27] Info
2018-04-21 11:42:03.260523+0800 ZHLog[75592:3057889] ❗️Important: -[ViewController viewDidLoad] [Line 28] Important
2018-04-21 11:42:03.260620+0800 ZHLog[75592:3057889] ❌Error: -[ViewController viewDidLoad] [Line 29] error
2018-04-21 11:42:03.260725+0800 ZHLog[75592:3057889] ⚠️Warning: -[ViewController viewDidLoad] [Line 30] warning
2018-04-21 11:42:03.260800+0800 ZHLog[75592:3057889] ✅Debug: -[ViewController viewDidLoad] [Line 33] tofile debug
2018-04-21 11:42:03.265322+0800 ZHLog[75592:3057889] 💧Info: -[ViewController viewDidLoad] [Line 34] tofile info
2018-04-21 11:42:03.265828+0800 ZHLog[75592:3057889] ⚠️Warning: -[ViewController viewDidLoad] [Line 35] tofile warning
2018-04-21 11:42:03.266318+0800 ZHLog[75592:3057889] ❌Error: -[ViewController viewDidLoad] [Line 36] tofile error
2018-04-21 11:42:03.266805+0800 ZHLog[75592:3057889] 💧Info: -[ViewController viewDidLoad] [Line 37] tofile important
2018-04-21 11:42:03.267331+0800 ZHLog[75592:3057889] ✅Debug: -[ViewController viewDidLoad] [Line 33] tofile debug
日志文件显示截图
2018-04-21 11:38:06:✅Debug: -[ViewController viewDidLoad] [Line 33] tofile debug
2018-04-21 11:38:06:💧Info: -[ViewController viewDidLoad] [Line 34] tofile info
2018-04-21 11:38:06:⚠️Warning: -[ViewController viewDidLoad] [Line 35] tofile warning
2018-04-21 11:38:06:❌Error: -[ViewController viewDidLoad] [Line 36] tofile error
2018-04-21 11:38:06:❗️Important: -[ViewController viewDidLoad] [Line 37] tofile important
2018-04-21 11:38:06:✅Debug: -[ViewController viewDidLoad] [Line 33] tofile debug
2018-04-21 11:38:06:💧Info: -[ViewController viewDidLoad] [Line 34] tofile info
2018-04-21 11:38:06:⚠️Warning: -[ViewController viewDidLoad] [Line 35] tofile warning
2018-04-21 11:38:06:❌Error: -[ViewController viewDidLoad] [Line 36] tofile error
2018-04-21 11:38:06:❗️Important: -[ViewController viewDidLoad] [Line 37] tofile important