aboutsummaryrefslogtreecommitdiffstats
path: root/Software
diff options
context:
space:
mode:
Diffstat (limited to 'Software')
-rw-r--r--Software/Visual_Studio/Tango.Logging/ApplicationLogFileParser.cs47
1 files changed, 25 insertions, 22 deletions
diff --git a/Software/Visual_Studio/Tango.Logging/ApplicationLogFileParser.cs b/Software/Visual_Studio/Tango.Logging/ApplicationLogFileParser.cs
index 1530c4d27..6bd53f433 100644
--- a/Software/Visual_Studio/Tango.Logging/ApplicationLogFileParser.cs
+++ b/Software/Visual_Studio/Tango.Logging/ApplicationLogFileParser.cs
@@ -84,32 +84,35 @@ namespace Tango.Logging
private 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)
+ if(File.Exists(file))
{
- try
+ 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)
{
- DateTime date = DateTime.ParseExact(logs[i].Replace("[", "").Replace("]", ""), "HH:mm:ss.ff", CultureInfo.InvariantCulture);
- String rest = logs[i + 1];
-
- var matches = Regex.Matches(rest, @"(?<=\[)(.*?)(?=\])");
+ try
+ {
+ DateTime date = DateTime.ParseExact(logs[i].Replace("[", "").Replace("]", ""), "HH:mm:ss.ff", CultureInfo.InvariantCulture);
+ String rest = logs[i + 1];
- 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), matches[0].ToString());
- item.CallerFile = matches[1].ToString();
- item.CallerMethodName = matches[2].ToString();
- item.CallerLineNumber = int.Parse(matches[3].ToString());
+ var matches = Regex.Matches(rest, @"(?<=\[)(.*?)(?=\])");
- int messageStartIndex = matches[3].Index + matches[3].Length + 2;
- item.Message = rest.Substring(messageStartIndex, rest.Length - messageStartIndex);
- logItems.Add(item);
- }
- catch (Exception ex)
- {
- LogManager.Default.Log(ex, "Could not parse log line: " + logs[i]);
+ 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), 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 = rest.Substring(messageStartIndex, rest.Length - messageStartIndex);
+ logItems.Add(item);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Default.Log(ex, "Could not parse log line: " + logs[i]);
+ }
}
}
}