From b97221dbb31b8baa930a26937dad3ac17b489968 Mon Sep 17 00:00:00 2001 From: Erica Eaton Date: Tue, 14 Mar 2023 13:05:20 -0700 Subject: [PATCH] add null checks for logging plugin --- .../java/com/amplifyframework/devmenu/DeveloperMenu.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/amplifyframework/devmenu/DeveloperMenu.java b/core/src/main/java/com/amplifyframework/devmenu/DeveloperMenu.java index 792834fc47..ea0ef8f3d5 100644 --- a/core/src/main/java/com/amplifyframework/devmenu/DeveloperMenu.java +++ b/core/src/main/java/com/amplifyframework/devmenu/DeveloperMenu.java @@ -126,6 +126,9 @@ public void setOnHideAction(HideAction action) { * @return the stored logs as a String. */ public String getLogs() { + if (loggingPlugin == null) { + return "No logs to display."; + } List logs = loggingPlugin.getLogs(); if (logs.isEmpty()) { return "No logs to display."; @@ -143,6 +146,9 @@ public String getLogs() { * @return the stored logs as a String. */ public String getFilteredLogs(@Nullable String searchText, @Nullable LogLevel logLevel) { + if (loggingPlugin == null) { + return "No logs to display."; + } if (Empty.check(searchText) && logLevel == null) { return getLogs(); } @@ -184,7 +190,7 @@ public String createIssueBody(String description, boolean includeLogs) { } String deviceInfo = new DeviceInfo().toString(); String logsText = ""; - if (includeLogs && !loggingPlugin.getLogs().isEmpty()) { + if (includeLogs && loggingPlugin != null && !loggingPlugin.getLogs().isEmpty()) { logsText = "**Logs**\n```\n" + getLogs() + "```"; } return String.format(Locale.US, "**Issue Description**\n%s\n\n**Environment Information**\n%s\n\n" +