Beispiel #1
0
        internal Totals Parse(LogStatsParams logParams, InputReader inputReader)
        {
            int lineCount = 0;
            Totals totals = new Totals(logParams.GroupByMode);

            string line;

            while ((line = inputReader.ReadLine()) != null)
            {
                ++lineCount;
                try
                {
                    LogEntry entry = ReadEntry(line, logParams.HasToFailOnError);
                    totals.SumEntry(entry);
                }
                catch (Exception e)
                {
                    string msg = string.Format("(line {0}) {1}", lineCount, e.Message);
                    if (logParams.HasToFailOnError)
                        throw new Exception(msg);
                    else
                        LogError(msg);
                }
            }

            Console.WriteLine("{0} lines read", lineCount);
            return totals;
        }