bugly使用

导入:

1.Bugly.framework

2.Security.framework

3.SystemConfiguration.framework

4.libc++.1.dylib

5.libz.1.dylib

AppDelegate.m 设置如下:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    

    [self setupBugly];

    

    return YES;

}

- (void)setupBugly {

    // Get the default config

    BuglyConfig * config = [[BuglyConfig alloc] init];

    

    // Open the debug mode to print the sdk log message.

    // Default value is NO, please DISABLE it in your RELEASE version.

#if DEBUG

    config.debugMode = YES;

#endif

    

    // Open the customized log record and report, BuglyLogLevelWarn will report Warn, Error log message.

    // Default value is BuglyLogLevelSilent that means DISABLE it.

    // You could change the value according to you need.

    config.reportLogLevel = BuglyLogLevelWarn;

    

    // Open the STUCK scene data in MAIN thread record and report.

    // Default value is NO

    config.blockMonitorEnable = YES;

    

    // Set the STUCK THRESHOLD time, when STUCK time > THRESHOLD it will record an event and report data when the app launched next time.

    // Default value is 3.5 second.

    config.blockMonitorTimeout = 1.5;

    

    // Set the app channel to deployment

    config.channel = @"Bugly";

    

    config.delegate = self;

    

    // NOTE:Required

    // Start the Bugly sdk with APP_ID and your config

    [Bugly startWithAppId:BUGLY_APP_ID

#if DEBUG

        developmentDevice:YES

#endif

                   config:config];

    

    // Set the customizd tag thats config in your APP registerd on the  bugly.qq.com

    // [Bugly setTag:1799];

    

    [Bugly setUserIdentifier:[NSString stringWithFormat:@"User: %@", [UIDevice currentDevice].name]];

    

    [Bugly setUserValue:[NSProcessInfo processInfo].processName forKey:@"Process"];

    

    // NOTE: This is only TEST code for BuglyLog , please UNCOMMENT it in your code.

    //[self performSelectorInBackground:@selector(testLogOnBackground) withObject:nil];

}

/**

 *    @brief TEST method for BuglyLog

 */

- (void)testLogOnBackground {

    int cnt = 0;

    while (1) {

        cnt++;

        

        switch (cnt % 5) {

            case 0:

                BLYLogError(@"Test Log Print %d", cnt);

                break;

            case 4:

                BLYLogWarn(@"Test Log Print %d", cnt);

                break;

            case 3:

                BLYLogInfo(@"Test Log Print %d", cnt);

                BLYLogv(BuglyLogLevelWarn, @"BLLogv: Test", NULL);

                break;

            case 2:

                BLYLogDebug(@"Test Log Print %d", cnt);

                BLYLog(BuglyLogLevelError, @"BLLog : %@", @"Test BLLog");

                break;

            case 1:

            default:

                BLYLogVerbose(@"Test Log Print %d", cnt);

                break;

        }

        

        // print log interval 1 sec.

        sleep(1);

    }

}

#pragma mark - BuglyDelegate

- (NSString *)attachmentForException:(NSException *)exception {

    NSLog(@"(%@:%d) %s %@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__,exception);

    

    return @"This is an attachment";

}

原文地址:https://www.cnblogs.com/tony0571/p/6029144.html