sergey-su / logjoint

LogJoint log viewer core. Viewer plugins for publicly-available domains.
MIT License
55 stars 13 forks source link

Handle bad json logging files #11

Closed sabrogden closed 5 years ago

sabrogden commented 5 years ago

We log json to the console but sometimes somebody does a console.log that cause some random text to get logged not in json. Logjoint really doesn't like this. Can LogJoint handle this. Best would be to strip out everything outside of json tags, or only have that line fail and keep loading / showing future lines, currently it just bombs out.

possible solution in JsonLogReader.cs, remove every after the last } before JObject.Parse(messageStr) messageStr = messageStr.Substring(0, messageStr.LastIndexOf("}") + 1);

Example

{"message":"a","level":"info","timestamp":"2019-04-10T22:15:03.324Z"} {"message":"b","level":"info","timestamp":"2019-04-10T22:15:03.327Z"} test {"message":"c","level":"info","timestamp":"2019-04-10T22:15:03.343Z"}

sergey-su commented 5 years ago

Fixed. Thanks for suggestion. Implemented it slightly more generic way.

sabrogden commented 5 years ago

Verified it works, thanks.

scott