diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-02-02 14:02:00 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-02-02 14:02:00 +0200 |
| commit | cf81fa5d4c4927858f312cfa520f2acd58a2e2e3 (patch) | |
| tree | ab40b4481254290d273e13a1b3381d82480031f1 /Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/ApplicationLogViewerParser.cs | |
| parent | aaa93103ae4db626d29081ce247df3b6143a39f8 (diff) | |
| download | Tango-cf81fa5d4c4927858f312cfa520f2acd58a2e2e3.tar.gz Tango-cf81fa5d4c4927858f312cfa520f2acd58a2e2e3.zip | |
GUI changes according to review item.
Related Work Items: #2402
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/ApplicationLogViewerParser.cs')
| -rw-r--r-- | Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/ApplicationLogViewerParser.cs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/ApplicationLogViewerParser.cs b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/ApplicationLogViewerParser.cs index 93d856b2e..1a43a7eff 100644 --- a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/ApplicationLogViewerParser.cs +++ b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/ApplicationLogViewerParser.cs @@ -21,28 +21,33 @@ namespace Tango.LogViewer.UI.LogViewerFileParser String text = File.ReadAllText(file); var logs = Regex.Split(text, @"(\[\d{2}:\d{2}:\d{2}.\d{2}\])"); + String logText = String.Empty; + for (int i = 1; i < logs.Length; i += 2) { try { DateTime date = DateTime.ParseExact(logs[i].Replace("[", "").Replace("]", ""), "HH:mm:ss.ff", CultureInfo.InvariantCulture); - String rest = logs[i + 1]; - var entries = Regex.Split(rest, @"\[(.*?)\]"); + logText = logs[i + 1]; + var matches = Regex.Matches(logText, @"(?<=\[)(.*?)(?=\])"); MessageLogItem item = new MessageLogItem(); item.TimeStamp = new DateTime(datetime.Year, datetime.Month, datetime.Day, date.Hour, date.Minute, date.Second, date.Millisecond); - item.Category = (LogCategory)Enum.Parse(typeof(LogCategory), entries[1]); - item.CallerFile = entries[3]; - item.CallerMethodName = entries[5]; - item.CallerLineNumber = int.Parse(entries[7]); - item.Message = new String(entries[8].Skip(2).ToArray()); + item.Category = (LogCategory)Enum.Parse(typeof(LogCategory), matches[0].ToString()); + item.CallerFile = matches[1].ToString(); + item.CallerMethodName = matches[2].ToString(); + item.CallerLineNumber = int.Parse(matches[3].ToString()); + + int messageStartIndex = matches[3].Index + matches[3].Length + 2; + + item.Message = logText.Substring(messageStartIndex, logText.Length - messageStartIndex); logItems.Add(item); } catch (Exception ex) { - //LogManager.Default.Log(ex, "Could not parse log line: " + logs[i]); + LogManager.Default.Log(ex, "Could not parse log line: " + logText); } } } |
