Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FileBackedLogMessageCollection"/> class backed by
        /// a <see cref="LogFile"/>.
        /// </summary>
        /// <param name="file">Log file to work on.</param>
        /// <exception cref="ArgumentNullException"><paramref name="file"/> is <c>null</c>.</exception>
        internal FileBackedLogMessageCollection(LogFile file)
        {
            LogFile = file ?? throw new ArgumentNullException(nameof(file));
            mCacheStartMessageId = LogFile.OldestMessageId;
            if (mCacheStartMessageId < 0)
            {
                mCacheStartMessageId = 0;
            }

            // populate overview collections
            foreach (string name in LogFile.GetLogWriterNames(true))
            {
                UsedLogWritersWritable.Add(name);
            }
            foreach (string name in LogFile.GetLogLevelNames(true))
            {
                UsedLogLevelsWritable.Add(name);
            }
            foreach (string name in LogFile.GetTags(true))
            {
                UsedTagsWritable.Add(name);
            }
            foreach (string name in LogFile.GetApplicationNames(true))
            {
                UsedApplicationNamesWritable.Add(name);
            }
            foreach (string name in LogFile.GetProcessNames(true))
            {
                UsedProcessNamesWritable.Add(name);
            }
            foreach (int id in LogFile.GetProcessIds())
            {
                UsedProcessIdsWritable.Add(id);
            }
        }