Esempio n. 1
0
 public void SetLastMaxPosition(LogPos logPos)
 {
     LastMaxLogPosition = logPos;
     LastMaxPosition    = Reader.GetPosition();
     lastFileLength     = new FileInfo(Filename).Length;
     LastMaxLine        = LoglineObject.ReadLine(logPos);
     IsDisposed         = false;
 }
Esempio n. 2
0
        public void Poll()
        {
            if (isBusy || isReleased || streamingHosts.Count == 0)
            {
                return;
            }

            isBusy = true;

            long newPositions = 0;

            foreach (StreamingHost sh in streamingHosts)
            {
                int isBigger = sh.HasChanged();
                if (isBigger > 0)
                {
                    if (sh.LastMaxLine == LoglineObject.ReadLine(sh.LastMaxLogPosition))
                    {
                        newPositions += ScanFile(null, 0, sh);
                    }
                    else
                    {
                        SetInconsistent();
                        return;
                    }
                }
                else if (isBigger < 0)
                {
                    SetInconsistent();
                    return;
                }
            }

            if (newPositions > 0 && NewPositions != null)
            {
                MainForm.FlashTrayIcon();
                NewPositions.Invoke(this, EventArgs.Empty);
            }
            isBusy = false;
        }
Esempio n. 3
0
        private static bool MatchSearch(LogPos logPos, SearchEventArgs e)
        {
            bool   addLine = true;
            String line    = LoglineObject.ReadLine(logPos);

            if (line == null)
            {
                return(false);
            }

            addLine &= SearchText(e, addLine, line);

            if (e.LogSource != null && logPos.LogSource != e.LogSource)
            {
                addLine &= false;
            }

            if (e.SearchDuration)
            {
                int posMs2 = line.LastIndexOf(" ms");
                if (posMs2 > 0)
                {
                    int    posMs1 = line.LastIndexOf(" ", posMs2 - 1);
                    String ms     = line.Substring(posMs1 + 1, posMs2 - posMs1 - 1);
                    int    val;
                    if (Int32.TryParse(ms, out val))
                    {
                        if (!(val >= e.DurationFrom && (val <= e.DurationTo || e.DurationTo == 0)))
                        {
                            addLine &= false;
                        }
                    }
                    else
                    {
                        addLine &= false;
                    }
                }
                else
                {
                    addLine &= false;
                }
            }

            if (e.OnlyLinesWithStackTrace)
            {
                if (logPos.Childs == null)
                {
                    addLine &= false;
                }
            }

            if (!e.LevelTrace || !e.LevelDebug || !e.LevelInfo || !e.LevelWarn || !e.LevelError || !e.LevelFatal)
            {
                if (line.Length > 29)
                {
                    String level = line.Substring(24, 5);
                    switch (level)
                    {
                    case "TRACE":
                        if (!e.LevelTrace)
                        {
                            addLine &= false;
                        }
                        break;

                    case "DEBUG":
                        if (!e.LevelDebug)
                        {
                            addLine &= false;
                        }
                        break;

                    case "INFO ":
                        if (!e.LevelInfo)
                        {
                            addLine &= false;
                        }
                        break;

                    case "WARN ":
                        if (!e.LevelWarn)
                        {
                            addLine &= false;
                        }
                        break;

                    case "ERROR":
                        if (!e.LevelError)
                        {
                            addLine &= false;
                        }
                        break;

                    case "FATAL":
                        if (!e.LevelFatal)
                        {
                            addLine &= false;
                        }
                        break;

                    default:
                        addLine &= false;
                        break;
                    }
                }
                else
                {
                    addLine &= false;
                }
            }

            return(addLine);
        }