public IEnumerable <JournalEntry> GetJournalEntries()
 {
     return(_lineSources
            .SelectMany(s => s.GetJournalLines())
            .Select(l =>
     {
         try
         {
             return new JournalEntry(l.Context, _parser.Parse(l.Line));
         }
         catch (JournalParseException e)
         {
             Log.Error($"'{l.Context.Filename}': {e.JournalFragment}", e);
         }
         catch (UnrecognizedJournalException e)
         {
             Log.Warn($"'{l.Context.Filename}': {e.JournalFragment}", e);
         }
         return null;
     })
            .Where(x => x?.Entry != null && x.Entry.Timestamp >= _startTime));
 }
        private JournalLogFileInfo ReadFileInfo()
        {
            FileHeader     fileHeader = null;
            var            info       = new JournalLogFileInfo(File);
            DateTimeOffset?lastEntry  = null;

            try
            {
                // Get a new reader for this action only
                using (var streamReader = GetStreamReader())
                {
                    // FileHeader *should* be the first line in the file, but at least try the first 5
                    var tolerance = 5;

                    while (!streamReader.EndOfStream && tolerance > 0 && fileHeader == null)
                    {
                        var line = streamReader.ReadLine();
                        if (string.IsNullOrWhiteSpace(line))
                        {
                            continue;
                        }

                        try
                        {
                            var(eventType, timestamp) = _parser.ParseCommonProperties(line);

                            if (timestamp > (lastEntry ?? DateTimeOffset.MinValue))
                            {
                                lastEntry = timestamp;
                            }

                            if (eventType?.Equals(nameof(FileHeader), StringComparison.InvariantCultureIgnoreCase) == true)
                            {
                                fileHeader = _parser.Parse <FileHeader>(line);
                            }
                        }
                        catch (JournalParseException)
                        {
                            // Cannot parse line, don't consider as potential fileheader
                        }

                        tolerance--;
                    }
                }

                if (fileHeader != null)
                {
                    info = new JournalLogFileInfo(File, fileHeader.GameVersion, fileHeader.Timestamp, lastEntry ?? fileHeader.Timestamp);
                }
            }
            catch (FileNotFoundException e)
            {
                Log.Error($"Could not read file '{e.FileName}'", e);
            }
            catch (IOException e)
            {
                Log.Error($"Could not read file '{File.FullName}'", e);
            }

            return(info);
        }