Skip to content

Commit 8697d76

Browse files
authored
Fix error logging (#430)
1 parent 81c028f commit 8697d76

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

AndroidSDKCore/src/main/java/com/leanplum/LeanplumInbox.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public void response(JSONObject response) {
366366

367367
JSONObject messagesDict = response.optJSONObject(Constants.Keys.INBOX_MESSAGES);
368368
if (messagesDict == null) {
369-
Log.e("No inbox messages found in the response from the server.", response);
369+
Log.e("No inbox messages found in the response from the server. %s", response);
370370
return;
371371
}
372372
int unreadCount = 0;

AndroidSDKCore/src/main/java/com/leanplum/annotations/Parser.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ public void handle(Var<T> variable) {
6565
field.setAccessible(false);
6666
}
6767
} catch (IllegalArgumentException e) {
68-
Log.e("Leanplum", "Invalid value " + var.value() +
69-
" for field " + var.name(), e);
68+
Log.e("Invalid value " + var.value() + " for field " + var.name(), e);
7069
} catch (IllegalAccessException e) {
71-
Log.e("Leanplum", "Error setting value for field " + var.name(), e);
70+
Log.e("Error setting value for field " + var.name(), e);
7271
}
7372
}
7473
});
@@ -100,10 +99,9 @@ public void handle(Var<String> variable) {
10099
field.setAccessible(false);
101100
}
102101
} catch (IllegalArgumentException e) {
103-
Log.e("Leanplum", "Invalid value " + var.value() +
104-
" for field " + var.name(), e);
102+
Log.e("Invalid value " + var.value() + " for field " + var.name(), e);
105103
} catch (IllegalAccessException e) {
106-
Log.e("Leanplum", "Error setting value for field " + var.name(), e);
104+
Log.e("Error setting value for field " + var.name(), e);
107105
}
108106
}
109107
});
@@ -118,7 +116,7 @@ public static void parseVariables(Object... instances) {
118116
parseVariablesHelper(instance, instance.getClass());
119117
}
120118
} catch (Throwable t) {
121-
Log.e("Leanplum", "Error parsing variables", t);
119+
Log.e("Error parsing variables", t);
122120
}
123121
}
124122

@@ -131,7 +129,7 @@ public static void parseVariablesForClasses(Class<?>... classes) {
131129
parseVariablesHelper(null, clazz);
132130
}
133131
} catch (Throwable t) {
134-
Log.e("Leanplum", "Error parsing variables", t);
132+
Log.e("Error parsing variables", t);
135133
}
136134
}
137135

AndroidSDKCore/src/main/java/com/leanplum/internal/Log.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ public static void e(String msg, Object... args) {
4848
log(LogType.ERROR, msg, args);
4949
}
5050

51+
public static void e(String msg, Throwable throwable) {
52+
if (msg != null && msg.contains("%s")) {
53+
log(LogType.ERROR, msg, getStackTraceString(throwable));
54+
} else {
55+
log(LogType.ERROR, msg + "\n" + getStackTraceString(throwable));
56+
}
57+
}
58+
5159
public static void i(String msg, Object... args) {
5260
log(LogType.INFO, msg, args);
5361
}

AndroidSDKCore/src/main/java/com/leanplum/internal/RequestUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static JSONObject getResponseForId(JSONObject response, String reqId) {
2828
}
2929
}
3030
} catch (JSONException e) {
31-
Log.e("Could not get response for id: ", reqId, e);
31+
Log.e("Could not get response for id: " + reqId, e);
3232
return null;
3333
}
3434
return null;

AndroidSDKPush/src/main/java/com/leanplum/LeanplumPushService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ private static void showNotification(Context context, final Bundle message) {
344344
customizer.customize(notificationCompatBuilder, message);
345345
}
346346
} catch (Throwable t) {
347-
Log.e("Unable to customize push notification: ", Log.getStackTraceString(t));
347+
Log.e("Unable to customize push notification: %s", Log.getStackTraceString(t));
348348
return;
349349
}
350350
} else {

0 commit comments

Comments
 (0)