#日志
pod 'CocoaLumberjack'
更新pod install
完成
#import <DDLog.h>//整個框架的基礎
#import <DDASLLogger.h>//發送日志語句到蘋果的日志系統,以便它們顯示在Console.app上
#import <DDTTYLogger.h>//發送日志語句到Xcode控制台,如果可用
#import <DDFileLogger.h>//把日志語句發送至文件
DDFileLogger *fileLogger = [[DDFileLogger alloc] init];
fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
[DDLog addLogger:fileLogger];
DDLogVerbose(@"Verbose");
DDLogDebug(@"Debug");
DDLogInfo(@"Info");
DDLogWarn(@"Warn");
DDLogError(@"Error");
- // CONVERT FROM THIS
- #import "Sprocket.h"
- @implementation Sprocket
- - (void)someMethod
- {
- NSLog(@"Meet George Jetson");
- }
- @end
- // TO THIS
- #import "Sprocket.h"
- #import "DDLog.h"
- static const int ddLogLevel = LOG_LEVEL_VERBOSE;
- @implementation Sprocket
- - (void)someMethod
- {
- DDLogVerbose(@"Meet George Jetson");
- }
- @end
#import "AppDelegate.h"
//日志
#import <DDLog.h>//整個框架的基礎
#import <DDASLLogger.h>//發送日志語句到蘋果的日志系統,以便它們顯示在Console.app上
#import <DDTTYLogger.h>//發送日志語句到Xcode控制台,如果可用
#import <DDFileLogger.h>//把日志語句發送至文件
//日志級別閾值以上的DDLog語句都將編譯到你的項目中。
//DDLog 必須配置打印級別
//下面的這些不同的日志等級也許正有你所需要的:
//1.如果你將日志級別設置為 LOG_LEVEL_ERROR,那么你只會看到DDlogError語句。
//2.如果你將日志級別設置為LOG_LEVEL_WARN,那么你只會看到DDLogError和DDLogWarn語句。
//3.如果您將日志級別設置為 LOG_LEVEL_INFO,那么你會看到error、Warn和Info語句。
//4.如果您將日志級別設置為LOG_LEVEL_VERBOSE,那么你會看到所有DDLog語句。
//5.如果您將日志級別設置為 LOG_LEVEL_OFF,你將不會看到任何DDLog語句。
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// [DDLog addLogger:[DDASLLogger sharedInstance]];
[DDLog addLogger:[DDTTYLogger sharedInstance]];
DDFileLogger *fileLogger = [[DDFileLogger alloc] init];
fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
[DDLog addLogger:fileLogger];
DDLogVerbose(@"Verbose");
DDLogDebug(@"Debug");
DDLogInfo(@"Info");
DDLogWarn(@"Warn");
DDLogError(@"Error");
}