Exemple #1
0
        public void ParseLog(WatchedFile file)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();

            long   lines = 0;
            string line;

            var thisFilePlugins = _plugins.Where(p => p.Enabled && p.BeforeFile(file.Path));

            log.InfoFormat("Starting file: {0}", file.Path);

            if (thisFilePlugins.Count() > 0)
            {
                using (var logFile = new LogFileReader(file.Path))
                {
                    if (file.LastReadFileSize > 0)
                    {
                        logFile.Seek(file.LastReadFileSize);
                    }

                    while ((line = logFile.ReadLine()) != null)
                    {
                        foreach (var plugin in thisFilePlugins)
                        {
                            plugin.ParseLine(file.Path, line);
                        }
                        lines++;
                    }

                    foreach (var plugin in thisFilePlugins)
                    {
                        plugin.AfterFile(file.Path);
                    }
                }
            }

            log.InfoFormat("{0} lines processed in {1}.", lines, watch.Elapsed);
        }
        public void ParseLog(WatchedFile file)
        {
            Stopwatch watch = new Stopwatch();
            watch.Start();

            long lines = 0;
            string line;

            var thisFilePlugins = _plugins.Where(p => p.Enabled && p.BeforeFile(file.Path));

            log.InfoFormat("Starting file: {0}", file.Path);

            if (thisFilePlugins.Count() > 0)
            {

                using (var logFile = new LogFileReader(file.Path))
                {
                    if (file.LastReadFileSize > 0)
                        logFile.Seek(file.LastReadFileSize);

                    while ((line = logFile.ReadLine()) != null)
                    {
                        foreach (var plugin in thisFilePlugins)
                        {
                            plugin.ParseLine(file.Path, line);
                        }
                        lines++;
                    }

                    foreach (var plugin in thisFilePlugins)
                    {
                        plugin.AfterFile(file.Path);
                    }
                }
            }

            log.InfoFormat("{0} lines processed in {1}.", lines, watch.Elapsed);
        }