Пример #1
0
        public bool ProcessLogs()
        {
            LogConsumer.OnProgress -= LogConsumer_OnProgress;
            LogConsumer.OnProgress += LogConsumer_OnProgress;

            bool done = false;
            var  logs = LogSource.GetLogSources();

            if (logs.Length == 0)
            {
                OnLogsProcessingProgress(this.GetType().Name, "No logs to process since no LogSources were retrieved.", LogLevel.Verbose);
            }
            for (int k = 0; k < logs.Length; k++)
            {
                LogReader.Open(logs[k]);
                OnLogsProcessingProgress(this.GetType().Name, string.Format("Started processing log source {0} ({1}/{2}).", LogReader.SourceName, k + 1, logs.Length), LogLevel.Verbose);
                while (!done && LogReader.HasMoreLines)
                {
                    string line = LogReader.ReadLine();
                    done = LogConsumer.ConsumeLogEntry(line, LogReader.LineNumber, LogReader.SourceName);
                }
                LogReader.Close();
                if (done)
                {
                    OnLogsProcessingProgress(this.GetType().Name, string.Format("LogConsumer is DONE. Terminated processing in log source {0} ({1}/{2}).", logs[k], k + 1, logs.Length), LogLevel.Verbose);
                    break;
                }
                else
                {
                    OnLogsProcessingProgress(this.GetType().Name, string.Format("LogConsumer is NOT DONE after processing log source {0} ({1}/{2}).", logs[k], k + 1, logs.Length), LogLevel.Verbose);
                }
            }
            return(done);
        }