Skip to content

Commit

Permalink
Merge pull request square#474 from square/py/version_info
Browse files Browse the repository at this point in the history
Add version info to stacktrace
  • Loading branch information
pyricau committed Mar 30, 2016
2 parents 44510ab + 5c01639 commit 37cb2b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import com.squareup.leakcanary.internal.HeapAnalyzerService;

import static android.text.format.Formatter.formatShortFileSize;
import static com.squareup.leakcanary.BuildConfig.GIT_SHA;
import static com.squareup.leakcanary.BuildConfig.LIBRARY_VERSION;
import static com.squareup.leakcanary.internal.LeakCanaryInternals.isInServiceProcess;
import static com.squareup.leakcanary.internal.LeakCanaryInternals.setEnabled;

Expand Down Expand Up @@ -112,7 +114,10 @@ public static String leakInfo(Context context, HeapDump heapDump, AnalysisResult
detailedString = "\n* Details:\n" + result.leakTrace.toDetailedString();
}
} else if (result.failure != null) {
info += "* FAILURE:\n" + Log.getStackTraceString(result.failure) + "\n";
// We duplicate the library version & Sha information because bug reports often only contain
// the stacktrace.
info += "* FAILURE in " + LIBRARY_VERSION + " " + GIT_SHA + ":" + Log.getStackTraceString(
result.failure) + "\n";
} else {
info += "* NO LEAK FOUND.\n\n";
}
Expand All @@ -137,9 +142,9 @@ public static String leakInfo(Context context, HeapDump heapDump, AnalysisResult
+ " API: "
+ Build.VERSION.SDK_INT
+ " LeakCanary: "
+ BuildConfig.LIBRARY_VERSION
+ LIBRARY_VERSION
+ " "
+ BuildConfig.GIT_SHA
+ GIT_SHA
+ "\n"
+ "* Durations: watch="
+ heapDump.watchDurationMs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
import static android.text.format.Formatter.formatShortFileSize;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static com.squareup.leakcanary.BuildConfig.GIT_SHA;
import static com.squareup.leakcanary.BuildConfig.LIBRARY_VERSION;
import static com.squareup.leakcanary.LeakCanary.leakInfo;
import static com.squareup.leakcanary.internal.LeakCanaryInternals.newSingleThreadExecutor;

Expand Down Expand Up @@ -273,9 +275,13 @@ void updateUi() {
if (result.failure != null) {
listView.setVisibility(GONE);
failureView.setVisibility(VISIBLE);
failureView.setText(
getString(R.string.leak_canary_failure_report) + Log.getStackTraceString(
result.failure));
String failureMessage = getString(R.string.leak_canary_failure_report)
+ LIBRARY_VERSION
+ " "
+ GIT_SHA
+ "\n"
+ Log.getStackTraceString(result.failure);
failureView.setText(failureMessage);
setTitle(R.string.leak_canary_analysis_failed);
invalidateOptionsMenu();
getActionBar().setDisplayHomeAsUpEnabled(true);
Expand Down

0 comments on commit 37cb2b7

Please sign in to comment.