private void source_LinesAdded(object sender, LogLineEventArgs args) { lock (m_sync) { if (!m_updating) { m_updating = true; m_received = args.Line; m_syncContext.Post(o => { if (m_firstSeen == null) { m_firstSeen = m_received; m_lastHandled = m_firstSeen; LogEntries.Add(new LogEntryViewModel(m_lastHandled, m_zeroTime)); } LogLineData next; while (true) { lock (m_sync) { next = m_lastHandled.Next; if (next == null) { m_updating = false; return; } } LogEntries.Add(new LogEntryViewModel(m_lastHandled, m_zeroTime)); m_lastHandled = next; } }, null); } } }
private void source_LinesAdded(object sender, LogLineEventArgs args) { if (m_firstSeen == null) { m_firstSeen = args.Line; } }
public void ClearLog() { lock (m_sync) { m_firstSeen = null; m_lastHandled = null; } fctb.Clear(); }
public Enumerator(LogLineLineReader reader) { lock (reader.m_sync) { m_parent = reader; m_first = m_parent.m_entry; m_current = null; } }
public void CheckRules(LogLineData line) { foreach (var rule in _orderedRules) { if (rule.CheckRule(line)) { break; } } }
public void NotifyNew(LogLineData entry) { lock (m_sync) { if (m_entry == null) { m_entry = entry; Monitor.Pulse(m_sync); // In case someone is waiting. } this.LinesAdded?.Invoke(this, EventArgs.Empty); } }
private void AddToLog(LogType type, uint id, string text) { try { System.Diagnostics.Debug.WriteLine($"TESTCONNECTION {type} {id}: {text}"); m_lastLogLine = new LogLineData(m_lastLogLine, type, id, text); if (m_firstLogLine == null) { m_firstLogLine = m_lastLogLine; } switch (type) { case LogType.ReceivedEnd: case LogType.ReceivedPartial: case LogType.ReceivedError: if (m_currentExecutingCommand != null) { var logger = m_currentExecutingCommand?.Context?.Logger; if (logger != null && m_currentExecutingCommand.Context.LoggingEnabled) { logger.LogDetail(this.DisplayName, "Received: " + text); } } break; case LogType.ReceivedAsync: if (m_mainLogger != null) { m_mainLogger.LogAsync(m_name, "Event: " + text); } if (m_asyncLogLineReader != null) { lock (m_eventLogSync) { m_lastEventLogLine = new LogLineData(m_lastEventLogLine, type, id, text); m_asyncLogLineReader.NotifyNew(m_lastEventLogLine); } } break; default: break; } LinesAdded?.Invoke(this, new LogLineEventArgs(m_lastLogLine)); } catch (Exception ex) { StepBro.Core.Main.RootLogger.LogError("SerialTestConnection.AddToLog", $"Unexpected error. Exception: {ex}"); } }
public bool Next() { lock (m_sync) { if (m_entry != null) { m_entry = m_entry.Next; return(true); } else { return(false); } } }
public void Flush(ILineReaderEntry stopAt = null) { if (stopAt != null) { lock (m_sync) { m_entry = (LogLineData)stopAt; } } else { lock (m_sync) { m_entry = null; } } }
private void AddEntry(LogLineData entry) { if (!m_filter(entry)) { return; } TextStyle style = StyleInfo; switch (entry.Type) { case LogLineData.LogType.Neutral: style = StyleInfo; break; case LogLineData.LogType.Sent: style = StyleSent; break; case LogLineData.LogType.ReceivedEnd: style = StyleReceived; break; case LogLineData.LogType.ReceivedPartial: style = StyleReceivedPartial; break; case LogLineData.LogType.ReceivedError: style = StyleReceivedError; break; case LogLineData.LogType.ReceivedAsync: style = StyleReceivedAsync; break; case LogLineData.LogType.ReceivedTrace: style = StyleReceivedAsync; break; default: break; } fctb.AppendText(entry.Timestamp.ToMinutesTimestamp(m_zeroTime), StyleTimestamp); fctb.AppendText(String.Concat(" ", entry.LineText, Environment.NewLine), style); }
public LogEntryViewModel(LogLineData entry, DateTime zero) { m_entry = entry; this.Timestamp = entry.Timestamp.ToMinutesTimestamp(zero); string type; switch (entry.Type) { case LogLineData.LogType.Sent: type = "Sent"; break; case LogLineData.LogType.ReceivedEnd: type = "Received"; break; case LogLineData.LogType.ReceivedPartial: type = "ReceivedPartial"; break; case LogLineData.LogType.ReceivedError: type = "Error"; break; case LogLineData.LogType.ReceivedAsync: type = "Async"; break; case LogLineData.LogType.ReceivedTrace: type = "Trace"; break; case LogLineData.LogType.Neutral: default: type = ""; break; } this.Type = type; }
public bool MoveNext() { if (m_current != null && m_current.Next != null) { m_current = m_current.Next; return(true); } else { if (m_reset && m_first != null) { m_current = m_first; m_reset = false; return(true); } else { m_current = null; return(false); } } }
private void updateTimer_Tick(object sender, EventArgs e) { if (m_lastHandled != null) { DateTime stopTime = DateTime.Now + TimeSpan.FromMilliseconds(updateTimer.Interval / 2); LogLineData entry = m_lastHandled.Next; if (entry != null) { //some stuffs for best performance fctb.BeginUpdate(); fctb.Selection.BeginUpdate(); //remember user selection var userSelection = fctb.Selection.Clone(); //add text with predefined style fctb.TextSource.CurrentTB = fctb; //bool gotoEnd = (userSelection.IsEmpty && userSelection.Start.iLine == (fctb.LinesCount - 1)); int i = 0; while ((i < 1000 || DateTime.Now < stopTime) && entry != null) { AddEntry(entry); m_lastHandled = entry; i++; entry = m_lastHandled.Next; } //restore user selection if (m_followEnd) { fctb.GoEnd();//scroll to end of the text } else { fctb.Selection.Start = userSelection.Start; fctb.Selection.End = userSelection.End; } // fctb.Selection.EndUpdate(); fctb.EndUpdate(); } } else { if (m_firstSeen != null) { //some stuffs for best performance fctb.BeginUpdate(); fctb.Selection.BeginUpdate(); //remember user selection var userSelection = fctb.Selection.Clone(); //add text with predefined style fctb.TextSource.CurrentTB = fctb; AddEntry(m_firstSeen); m_lastHandled = m_firstSeen; //restore user selection if (!userSelection.IsEmpty || userSelection.Start.iLine < fctb.LinesCount - 2) { fctb.Selection.Start = userSelection.Start; fctb.Selection.End = userSelection.End; } else { fctb.GoEnd();//scroll to end of the text } // fctb.Selection.EndUpdate(); fctb.EndUpdate(); } } }
public LogLineLineReader(INameable source, LogLineData first, object sync) { this.Source = source; m_sync = sync; m_entry = first; }
public void Dispose() { m_parent = null; m_first = null; m_current = null; }
public void Reset() { m_current = null; m_reset = true; }
/// <summary> /// Parses input data to detect python test result. /// </summary> /// <param name="data">Data to be parsed.</param> public void Parse(LogLineData Line) { throw new NotImplementedException(); }
/// <inheritdoc/> public void Parse(LogLineData testResultsLine) { }