From d26c931ae2c5d33adc5fc20842b7be838a2822b4 Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Tue, 19 Jun 2018 15:08:56 -0400
Subject: [PATCH] SL-821: Send the SecondLife.log from the previous (crashed)
 run.

Also clean up log messages.
---
 indra/newview/llappdelegate-objc.mm        | 16 +++++++++++-----
 indra/newview/llappviewermacosx-for-objc.h |  2 +-
 indra/newview/llappviewermacosx.cpp        |  4 ++--
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm
index 2ee294e1e68..4510f4070fe 100644
--- a/indra/newview/llappdelegate-objc.mm
+++ b/indra/newview/llappdelegate-objc.mm
@@ -196,21 +196,27 @@
 
 #if defined(LL_BUGSPLAT)
 
+#if 0
+// Apparently this override method only contributes the User Description field
+// of BugSplat's All Crashes table. Despite the method name, it would seem to
+// be a bad place to try to stuff all of SecondLife.log.
 - (NSString *)applicationLogForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager
 {
 //  return NSStringFromSelector(_cmd);
     infos("Reached applicationLogForBugsplatStartupManager");
     return @"[contents of SecondLife.log]";
 }
+#endif
 
 - (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager {
-    std::string logfile = getLogFilePathname();
-    infos("Reached attachmentForBugsplatStartupManager with:");
-    infos(logfile);
+    // We get the *old* log file pathname (for SecondLife.old) because it's on
+    // the run *following* the crash that BugsplatStartupManager notices that
+    // the previous run crashed and calls this override. By that time, we've
+    // already renamed SecondLife.log to SecondLife.old.
+    std::string logfile = getOldLogFilePathname();
     NSString *ns_logfile = [NSString stringWithCString:logfile.c_str()
                                               encoding:NSUTF8StringEncoding];
     NSData *data = [NSData dataWithContentsOfFile:ns_logfile];
-    infos("Read logfile");
 
     // Apologies for the hard-coded log-file basename, but I do not know the
     // incantation for "$(basename "$logfile")" in this language.
@@ -218,7 +224,7 @@
         [[BugsplatAttachment alloc] initWithFilename:@"SecondLife.log"
                                       attachmentData:data
                                          contentType:@"text/plain"];
-    infos("returning attachment");
+    infos("attachmentForBugsplatStartupManager: attaching " + logfile);
     return attachment;
 }
 
diff --git a/indra/newview/llappviewermacosx-for-objc.h b/indra/newview/llappviewermacosx-for-objc.h
index e45cb85861f..c4392976113 100644
--- a/indra/newview/llappviewermacosx-for-objc.h
+++ b/indra/newview/llappviewermacosx-for-objc.h
@@ -29,7 +29,7 @@ void handleUrl(const char* url_utf8);
 bool pumpMainLoop();
 void handleQuit();
 void cleanupViewer();
-std::string getLogFilePathname();
+std::string getOldLogFilePathname();
 void infos(const std::string& message);
 
 #endif /* ! defined(LL_LLAPPVIEWERMACOSX_FOR_OBJC_H) */
diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp
index 562e7ebfde8..d014e992f99 100644
--- a/indra/newview/llappviewermacosx.cpp
+++ b/indra/newview/llappviewermacosx.cpp
@@ -148,9 +148,9 @@ void cleanupViewer()
 	gViewerAppPtr = NULL;
 }
 
-std::string getLogFilePathname()
+std::string getOldLogFilePathname()
 {
-    return gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "SecondLife.log");
+    return gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "SecondLife.old");
 }
 
 void infos(const std::string& message)
-- 
GitLab