学习lumberjack framework(深入版)
生活随笔
收集整理的這篇文章主要介紹了
学习lumberjack framework(深入版)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
也許看了上面的簡單介紹,不知道如何去設置打印的級別,其實很簡單,我的做法是構造一個頭文件,因為我們會在很多的文件中用到這個級別設定,所以我們單獨列出來,那個文件用只需要去引用頭文件即可
在頭文件中寫入如下代碼
#import "DDLog.h" #import "DDTTYLogger.h" #import "DDASLLogger.h" #import "DDFileLogger.h"#if DEBUG static const int ddLogLevel = LOG_LEVEL_VERBOSE; #else static const int ddLogLevel = LOG_LEVEL_INFO; #endif
?其中if中是調試的時候的級別,下面else的級別是發布版本的時候的日志的級別,例如,我們希望向服務器拋出一些異常,那么我們就可以把debug級別設為LOG_LEVEL_VERBOSE 把發布版本的日志級別設為LOG_LEVEL_ERROR,這樣在發布的時候,應用程序只會把用DDLogError輸出的日志,寫到文件中,文件在應用程序的沙盒路徑的Caches的Logs文件夾中,我們要做的就是把這個文件夾發到服務器上。發布的方法如下
/*** 獲得系統日志的路徑**/ -(NSArray*)getLogPath {NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];NSString * logPath = [docPath stringByAppendingPathComponent:@"Caches"];logPath = [logPath stringByAppendingPathComponent:@"Logs"];NSFileManager * fileManger = [NSFileManager defaultManager];NSError * error = nil;NSArray * fileList = [[NSArray alloc]init];fileList = [fileManger contentsOfDirectoryAtPath:logPath error:&error];NSMutableArray * listArray = [[NSMutableArray alloc]init];for (NSString * oneLogPath in fileList){if([oneLogPath characterAtIndex:0 ] == 'l'){NSString * truePath = [logPath stringByAppendingPathComponent:oneLogPath];[listArray addObject:truePath];}}return listArray;}?
?轉載于:https://www.cnblogs.com/xiaoweige/archive/2012/10/08/2715120.html
總結
以上是生活随笔為你收集整理的学习lumberjack framework(深入版)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 出现错误(已解决)RuntimeErro
- 下一篇: button type属性