NSLog-----CocoaLumberjack
2013-01-16 14:20
288 查看
NSLog 就一般我們在AS3的trace()一樣,用在追蹤一些變數或function執行的前後順序,而Lumberjack 除了用來追蹤,另外還可以Filter一些訊息,如 DDLogError 的功能,只有在產生Error 的時候,才會 Print 錯誤訊息出來,沒有Error 的時候,並不會執行。
目前Lumberjack 分成幾個level,如下:
DDLogError–只會看到 Error 的訊息
DDLogWarn–只會看到 Error,warn的訊息
DDLogInfo—-只會看到 Error ,warn,Info 的訊息
DDLogVerbose–會看到全部的訊息
下載網址:https://github.com/robbiehanson/CocoaLumberjack
1.將 Lumberjack 套件增加到專案中。
2.如果不使用ARC的機制,必須要在Build Phases中,找到Lumberjack的檔案,如DDLog.m,DDFileLogger.m…等等。
3.double click,加上「-fobjc-arc」
4.在AppDelegate.m 中
以上四個步驟應該就可以使用 Lumberjack 的log 機制了,比如說在RootViewController.m 裡,為每個 function 都下DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD),這樣我們就可追蹤整個城市的流程了。
目前Lumberjack 分成幾個level,如下:
DDLogError–只會看到 Error 的訊息
DDLogWarn–只會看到 Error,warn的訊息
DDLogInfo—-只會看到 Error ,warn,Info 的訊息
DDLogVerbose–會看到全部的訊息
下載網址:https://github.com/robbiehanson/CocoaLumberjack
1.將 Lumberjack 套件增加到專案中。
2.如果不使用ARC的機制,必須要在Build Phases中,找到Lumberjack的檔案,如DDLog.m,DDFileLogger.m…等等。
3.double click,加上「-fobjc-arc」
4.在AppDelegate.m 中
#import "AppDelegate.h" #import "DDLog.h" #import "DDASLLogger.h" #import "DDTTYLogger.h" @implementation AppDelegate #pragma mark - define #ifdef DEBUG static const int ddLogLevel = LOG_LEVEL_VERBOSE; #else static const int ddLogLevel = LOG_LEVEL_WARN; #endif @synthesize window = _window; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; // setup logging framework [DDLog addLogger:[DDASLLogger sharedInstance]]; [DDLog addLogger:[DDTTYLogger sharedInstance]]; [self.window makeKeyAndVisible]; return YES; }
以上四個步驟應該就可以使用 Lumberjack 的log 機制了,比如說在RootViewController.m 裡,為每個 function 都下DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD),這樣我們就可追蹤整個城市的流程了。
#import "RootViewController.h" #import "DDLog.h" #ifdef DEBUG static const int ddLogLevel = LOG_LEVEL_VERBOSE; #else static const int ddLogLevel = LOG_LEVEL_WARN; #endif - (void)viewDidLoad { [super viewDidLoad]; DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD); } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD); }
相关文章推荐
- DDLog--CocoaLumberjack framework 自定义日志管理
- CocoaLumberjack使用以及日志文件获取
- CocoaLumberjack框架简单介绍
- Log---CocoaLumberjack
- CocoaLumberjack 学习总结(五)
- CocoaLumberjack 踩坑
- CocoaLumberjack的使用
- CocoaLumberjack 之坑
- CocoaLumberjack使用案例
- CocoaLumberjack的ios应用开发使用指南
- CocoaLumberjack彩色日志输出
- CocoaLumberjack
- cocoapod导入文件错误- `CocoaLumberjack (~> 2.0.0-rc2)` required by `Podfile`
- iOS 获取日志框架CocoaLumberjack
- [绍棠] iOS-CocoaLumberjack(DDLog)日志框架使用
- IOS开发小技巧——强大的企业级调试日志——IOS第三方库CocoaLumberjack/CocoaLumberjack(1)
- 使用CocoaLumberjack的一些问题记录
- CocoaLumberjack和XcodeColors定制个性化log系统
- 【ios笔记】CocoaLumberjack在Xcode8.0和7.2中使用差别
- CocoaLumberjack 学习纪录(五)