Skip to content

Commit

Permalink
[TIMOB-17793] Change the way log messages are passed across the bridg…
Browse files Browse the repository at this point in the history
…e and displayed so to prevent out of memory errors trying to JSON parse a huge string.
  • Loading branch information
cb1kenobi committed Sep 26, 2014
1 parent 91ecf6f commit 9b10dc3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion mobileweb/src/wp8.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
return it === void 0 ? 'undefined' : it === null ? 'null' : Array.isArray(it) ? JSON.stringify(it.map(function (f) {
return typeof f == 'function' ? f.toString() : f;
})) : objToString.call(it) == '[object Object]' ? JSON.stringify(it) : it;
}).join(' ')
})
});
};
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace TitaniumApp.TiRequestHandlers
{
Expand All @@ -9,25 +11,29 @@ public class LogRequestHandler : IRequestHandler

public TiResponse process(TiRequestParams data) {
if (data.ContainsKey("message")) {
string message = (string)data["message"];
JArray lines = (JArray)data["message"];

MatchCollection matches = logLevelRegex.Matches(message);
if (matches.Count > 0) {
GroupCollection groups = matches[0].Groups;
if (groups.Count > 2) {
string level = groups[1].Value.ToUpper();
Logger.log(level == "LOG" ? "INFO" : level, groups[2].Value);
for (int i = 0; i < lines.Count; i++) {
string message = (string)lines[i];

MatchCollection matches = logLevelRegex.Matches(message);
if (matches.Count > 0) {
GroupCollection groups = matches[0].Groups;
if (groups.Count > 2) {
string level = groups[1].Value.ToUpper();
Logger.log(level == "LOG" ? "INFO" : level, groups[2].Value);
return null;
}
}

if (data.ContainsKey("level")) {
string level = ((string)data["level"]).ToUpper();
Logger.log(level == "LOG" ? "INFO" : level, message);
return null;
}
}

if (data.ContainsKey("level")) {
string level = ((string)data["level"]).ToUpper();
Logger.log(level == "LOG" ? "INFO" : level, message);
return null;
Logger.log(message);
}

Logger.log(message);
}
return null;
}
Expand Down

0 comments on commit 9b10dc3

Please sign in to comment.