Commit 9cdcef4d authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

DRTVWR-447: Use new attachmentsForBugsplatStartupManager SDK method

to attach user settings file and static debug info file to Mac crash reports,
as well as SecondLife.log, just like Windows crash reports.
parent 72c0845a
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#import "llappdelegate-objc.h" #import "llappdelegate-objc.h"
#if defined(LL_BUGSPLAT) #if defined(LL_BUGSPLAT)
#include <boost/filesystem.hpp>
#include <vector>
@import BugsplatMac; @import BugsplatMac;
// derived from BugsplatMac's BugsplatTester/AppDelegate.m // derived from BugsplatMac's BugsplatTester/AppDelegate.m
@interface LLAppDelegate () <BugsplatStartupManagerDelegate> @interface LLAppDelegate () <BugsplatStartupManagerDelegate>
...@@ -271,25 +273,59 @@ ...@@ -271,25 +273,59 @@
infos("bugsplatStartupManagerWillSendCrashReport"); infos("bugsplatStartupManagerWillSendCrashReport");
} }
- (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { struct AttachmentInfo
std::string logfile = CrashMetadata_instance().logFilePathname; {
// Still to do: AttachmentInfo(const std::string& path, const std::string& type):
// userSettingsPathname pathname(path),
// staticDebugPathname basename(boost::filesystem::path(path).filename().string()),
// but the BugsplatMac version 1.0.5 BugsplatStartupManagerDelegate API mimetype(type)
// doesn't yet provide a way to attach more than one file. {}
NSString *ns_logfile = [NSString stringWithCString:logfile.c_str()
encoding:NSUTF8StringEncoding]; std::string pathname, basename, mimetype;
NSData *data = [NSData dataWithContentsOfFile:ns_logfile]; };
// Apologies for the hard-coded log-file basename, but I do not know the - (NSArray<BugsplatAttachment *> *)attachmentsForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager
// incantation for "$(basename "$logfile")" in this language. {
BugsplatAttachment *attachment = const CrashMetadata& metadata(CrashMetadata_instance());
[[BugsplatAttachment alloc] initWithFilename:@"SecondLife.log"
attachmentData:data // Since we must do very similar processing for each of several file
contentType:@"text/plain"]; // pathnames, start by collecting them into a vector so we can iterate
infos("attachmentForBugsplatStartupManager attaching " + logfile); // instead of spelling out the logic for each.
return attachment; std::vector<AttachmentInfo> info{
AttachmentInfo(metadata.logFilePathname, "text/plain"),
AttachmentInfo(metadata.userSettingsPathname, "text/xml"),
AttachmentInfo(metadata.staticDebugPathname, "text/xml")
};
// We "happen to know" that info[0].basename is "SecondLife.old" -- due to
// the fact that BugsplatMac only notices a crash during the viewer run
// following the crash. Replace .old with .log to reduce confusion.
info[0].basename =
boost::filesystem::path(info[0].pathname).stem().string() + ".log";
NSMutableArray *attachments = [[NSMutableArray alloc] init];
// Iterate over each AttachmentInfo in info vector
for (const AttachmentInfo& attach : info)
{
NSString *nspathname = [NSString stringWithCString:attach.pathname.c_str()
encoding:NSUTF8StringEncoding];
NSString *nsbasename = [NSString stringWithCString:attach.basename.c_str()
encoding:NSUTF8StringEncoding];
NSString *nsmimetype = [NSString stringWithCString:attach.mimetype.c_str()
encoding:NSUTF8StringEncoding];
NSData *nsdata = [NSData dataWithContentsOfFile:nspathname];
BugsplatAttachment *attachment =
[[BugsplatAttachment alloc] initWithFilename:nsbasename
attachmentData:nsdata
contentType:nsmimetype];
[attachments addObject:attachment];
infos("attachmentsForBugsplatStartupManager attaching " + attach.pathname);
}
return attachments;
} }
- (void)bugsplatStartupManagerDidFinishSendingCrashReport:(BugsplatStartupManager *)bugsplatStartupManager - (void)bugsplatStartupManagerDidFinishSendingCrashReport:(BugsplatStartupManager *)bugsplatStartupManager
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment