예제 #1
0
 public void WriteLogRecord(LogRecord logRecord)
 {
     List<LogRecord> logRecords = new List<LogRecord>();
     logRecords.Add(logRecord);
     WriteLogRecord(logRecords);
 }
예제 #2
0
 public LogRecord(string line)
 {
     this = new LogRecord(line, DEFAULT_DELIMITER);
 }
예제 #3
0
        public ReadOnlyCollection<LogRecord> ReadLogFile()
        {
            if (logOpenType == LogFileOpenType.Write)
                throw new LogFileException("File open for writing; cannot read file.", null);

            // clear the previously-read items and move to beginning of stream
            logRecords.Clear();
            stream.Position = 0;

            try
            {
                string line;

                // read each line until end
                while ((line = reader.ReadLine()) != null)
                {
                    if (!line.StartsWith("***") && line.Trim() != string.Empty)
                    {
                        LogRecord logRecord = new LogRecord(line, logFileDelimiter);

                        // only read-in if record is at least as high in priority as this.LogLevel
                        if (logRecord.LogLevel >= loggingLevel)
                            logRecords.Add(logRecord);
                    }
                }
            }
            catch (LogFileException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new LogFileException(
                    "Error reading from file; check inner exception for more detials.", e);
            }

            return this.ReadBuffer;
        }