Skip to content

Commit

Permalink
html encode log entries in AppLog.toHtml()
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Jan 14, 2015
1 parent c8a4d89 commit 5a48a06
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public static void e(T tag, String message) {
public static void e(T tag, String message, Throwable tr) {
Log.e(TAG + "-" + tag.toString(), message, tr);
addEntry(tag, LogLevel.e, message + " - exception: " + tr.getMessage());
addEntry(tag, LogLevel.e, "StackTrace: " + getHTMLStringStackTrace(tr));
addEntry(tag, LogLevel.e, "StackTrace: " + getStringStackTrace(tr));
}

public static void e(T tag, Throwable tr) {
Log.e(TAG + "-" + tag.toString(), tr.getMessage(), tr);
addEntry(tag, LogLevel.e, tr.getMessage());
addEntry(tag, LogLevel.e, "StackTrace: " + getHTMLStringStackTrace(tr));
addEntry(tag, LogLevel.e, "StackTrace: " + getStringStackTrace(tr));
}

public static void e(T tag, String volleyErrorMsg, int statusCode) {
Expand Down Expand Up @@ -113,15 +113,15 @@ private static class LogEntry {

private String toHtml() {
StringBuilder sb = new StringBuilder()
.append("<font color='")
.append("<font color=\"")
.append(logLevel.toHtmlColor())
.append("'>")
.append("\">")
.append("[")
.append(logTag.name())
.append("] ")
.append(logLevel.name())
.append(": ")
.append(logText)
.append(TextUtils.htmlEncode(logText).replace("\n", "<br />"))
.append("</font>");
return sb.toString();
}
Expand Down Expand Up @@ -164,9 +164,6 @@ private static String getStringStackTrace(Throwable throwable) {
return errors.toString();
}

private static String getHTMLStringStackTrace(Throwable throwable) {
return getStringStackTrace(throwable).replace("\n", "<br/>");
}

/*
* returns entire log as html for display (see AppLogViewerActivity)
Expand Down

0 comments on commit 5a48a06

Please sign in to comment.