实现在ios开发中cocoalumberjack发送log email_移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > 实现在ios开发中cocoalumberjack发送log email

实现在ios开发中cocoalumberjack发送log email

 2013/11/18 10:22:54  lianwei  博客园  我要评论(0)
  • 摘要:实现在ios开发中cocoalumberjack发送logemail,这是我转载的,原文:http://ios.662p.com/thread-148-1-1.html-(NSMutableArray*)errorLogData{NSUIntegermaximumLogFilesToReturn=MIN([KRLogManagersharedInstance].fileLogger.logFileManager.maximumNumberOfLogFiles,10)
  • 标签:实现 iOS 开发

实现在ios开发中cocoalumberjack发送log email ,这是我转载的,原文:http://ios.662p.com/thread-148-1-1.html

- (NSMutableArray *)errorLogData
{
    NSUInteger maximumLogFilesToReturn = MIN([KRLogManager sharedInstance].fileLogger.logFileManager.maximumNumberOfLogFiles, 10);
    NSMutableArray *errorLogFiles = [NSMutableArray arrayWithCapacity:maximumLogFilesToReturn];
    DDFileLogger *logger = [KRLogManager sharedInstance].fileLogger;
    NSArray *sortedLogFileInfos = [logger.logFileManager sortedLogFileInfos];
    for (int i = 0; i < MIN(sortedLogFileInfos.count, maximumLogFilesToReturn); i++) {
        DDLogFileInfo *logFileInfo = [sortedLogFileInfos objectAtIndex:i];
        NSData *fileData = [NSData dataWithContentsOfFile:logFileInfo.filePath];
        [errorLogFiles addObject:fileData];
    }
    return errorLogFiles;
}

- (void)composeEmailWithDebugAttachment
{
    if ([MFMailComposeViewController canSendMail]) {

        MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
        mailViewController.mailComposeDelegate = self;
        NSMutableData *errorLogData = [NSMutableData data];
        for (NSData *errorLogFileData in [self errorLogData]) {
            [errorLogData appendData:errorLogFileData];
        }
        [mailViewController addAttachmentData:errorLogData mimeType:@"text/plain" fileName:@"errorLog.txt"];
        [mailViewController setSubject:NSLocalizedString(@"Good Subject", @"");];
        [mailViewController setToRecipients:[NSArray arrayWithObject:@"some@email.com"]];

        [self presentModalViewController:mailViewController animated:YES];

    }

    else {
        NSString *message;

        message = NSLocalizedString(@"Sorry, your issue can't be reported right now. This is most likely because no mail accounts are set up on your iPad.", @"");
        [[[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles: nil] show];
    }
}

 

发表评论
用户名: 匿名