Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The answers here don't seem to account for the fact that there may be multiple log files. You can use your DDFileLogger instance's logFileManager property to loop through file information. Check out DDFileLogger.h for public methods and properties. The following may be of use:</p> <blockquote> <pre><code>- (NSString *)logsDirectory; - (NSArray *)unsortedLogFilePaths; - (NSArray *)unsortedLogFileNames; - (NSArray *)unsortedLogFileInfos; - (NSArray *)sortedLogFilePaths; - (NSArray *)sortedLogFileNames; - (NSArray *)sortedLogFileInfos; </code></pre> </blockquote> <p>Here is my solution for getting log data (and emailing it). Note that the default number of log files is 5 as of this writing.</p> <pre><code>- (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 &lt; 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 = NSLocalizedString(@"Sorry, your issue can't be reported right now. This is most likely because no mail accounts are set up on your mobile device.", @""); [[[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles: nil] show]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload