summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2018-10-16 16:53:06 -0400
committerNat Goodspeed <nat@lindenlab.com>2018-10-16 16:53:06 -0400
commit9cdcef4d501f4a7fec3b1c7051037df9db082278 (patch)
treee69643b46c9b2d77f8f36ec6f1afc972bc65331a /indra/newview
parent72c0845a243ebdf0293bf7665474cfc652492bc7 (diff)
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.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llappdelegate-objc.mm74
1 files changed, 55 insertions, 19 deletions
diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm
index f55304f30b..1d55537427 100644
--- a/indra/newview/llappdelegate-objc.mm
+++ b/indra/newview/llappdelegate-objc.mm
@@ -26,6 +26,8 @@
#import "llappdelegate-objc.h"
#if defined(LL_BUGSPLAT)
+#include <boost/filesystem.hpp>
+#include <vector>
@import BugsplatMac;
// derived from BugsplatMac's BugsplatTester/AppDelegate.m
@interface LLAppDelegate () <BugsplatStartupManagerDelegate>
@@ -271,25 +273,59 @@
infos("bugsplatStartupManagerWillSendCrashReport");
}
-- (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager {
- std::string logfile = CrashMetadata_instance().logFilePathname;
- // Still to do:
- // userSettingsPathname
- // staticDebugPathname
- // but the BugsplatMac version 1.0.5 BugsplatStartupManagerDelegate API
- // doesn't yet provide a way to attach more than one file.
- NSString *ns_logfile = [NSString stringWithCString:logfile.c_str()
- encoding:NSUTF8StringEncoding];
- NSData *data = [NSData dataWithContentsOfFile:ns_logfile];
-
- // Apologies for the hard-coded log-file basename, but I do not know the
- // incantation for "$(basename "$logfile")" in this language.
- BugsplatAttachment *attachment =
- [[BugsplatAttachment alloc] initWithFilename:@"SecondLife.log"
- attachmentData:data
- contentType:@"text/plain"];
- infos("attachmentForBugsplatStartupManager attaching " + logfile);
- return attachment;
+struct AttachmentInfo
+{
+ AttachmentInfo(const std::string& path, const std::string& type):
+ pathname(path),
+ basename(boost::filesystem::path(path).filename().string()),
+ mimetype(type)
+ {}
+
+ std::string pathname, basename, mimetype;
+};
+
+- (NSArray<BugsplatAttachment *> *)attachmentsForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager
+{
+ const CrashMetadata& metadata(CrashMetadata_instance());
+
+ // Since we must do very similar processing for each of several file
+ // pathnames, start by collecting them into a vector so we can iterate
+ // instead of spelling out the logic for each.
+ 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