diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-01-27 16:56:22 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-01-27 16:56:22 +0200 |
| commit | 2b9b4c5f44072fd1f06b24e181be0d5d482b463e (patch) | |
| tree | 0bb3fa51682509e79c4ab7625888d3d032c16448 /Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/EmbeddedLogViewerParser.cs | |
| parent | d675e2f2a9b826422a296704cbb99d8fb32c85e0 (diff) | |
| download | Tango-2b9b4c5f44072fd1f06b24e181be0d5d482b463e.tar.gz Tango-2b9b4c5f44072fd1f06b24e181be0d5d482b463e.zip | |
Implement embedded logs in LogViewer
Related Work Items: #2430
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/EmbeddedLogViewerParser.cs')
| -rw-r--r-- | Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/EmbeddedLogViewerParser.cs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/EmbeddedLogViewerParser.cs b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/EmbeddedLogViewerParser.cs new file mode 100644 index 000000000..1d0028f10 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/EmbeddedLogViewerParser.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Tango.Integration.Logging; +using Tango.Logging; + +namespace Tango.LogViewer.UI.LogViewerFileParser +{ + public class EmbeddedLogViewerParser : ILogViewerParser + { + public EmbeddedLogViewerParser() + { + + + } + public void Parse(string file, DateTime datetime, ref List<LogItemBase> logItems) + { + String text = File.ReadAllText(file); + var logs = Regex.Split(text, @"(\[\d{2}:\d{2}:\d{2}.\d{2}\])"); + + 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, @"\[(.*?)\]"); + + LogItemBase item = new EmbeddedLogItem(new PMR.Debugging.StartDebugLogResponse() + { + Category = (PMR.Debugging.DebugLogCategory)Enum.Parse(typeof(PMR.Debugging.DebugLogCategory), entries[1]), + FileName = entries[3], + LineNumber = uint.Parse(entries[5]), + ModuleId = uint.Parse(entries[7]), + Filter = uint.Parse(entries[9]), + Message = new String(entries[10].Skip(2).ToArray()) + }); + item.TimeStamp = new DateTime(datetime.Year, datetime.Month, datetime.Day, date.Hour, date.Minute, date.Second, date.Millisecond); + + logItems.Add(item); + } + catch (Exception ex) + { + //LogManager.Default.Log(ex, "Could not parse log line: " + logs[i]); + } + } + } + } +} |
