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);
            }
        }
Example #2
0
        /// <summary>
        /// Updates the overview collections as the specified message is removed from the collection.
        /// </summary>
        /// <param name="message">Message that is removed from the collection (null, if all messages are removed).</param>
        private void UpdateOverviewCollectionsOnRemove(TMessage message)
        {
            if (message != null)
            {
                // unregister a single message

                UnregisterForOverviewCollection(message.LogWriterName, mUsedLogWriterCounts, UsedLogWritersWritable);
                UnregisterForOverviewCollection(message.LogLevelName, mUsedLogLevelCounts, UsedLogLevelsWritable);
                UnregisterForOverviewCollection(message.Tags, mUsedTagsCounts, UsedTagsWritable);
                UnregisterForOverviewCollection(message.ApplicationName, mUsedApplicationNameCounts, UsedApplicationNamesWritable);
                UnregisterForOverviewCollection(message.ProcessName, mUsedProcessNameCounts, UsedProcessNamesWritable);
                UnregisterForOverviewCollection(message.ProcessId, mUsedProcessIdCounts, UsedProcessIdsWritable);
            }
            else
            {
                // unregister all messages

                mUsedLogWriterCounts.Clear();
                mUsedLogLevelCounts.Clear();
                mUsedTagsCounts.Clear();
                mUsedApplicationNameCounts.Clear();
                mUsedProcessNameCounts.Clear();
                mUsedProcessIdCounts.Clear();

                UsedLogWritersWritable.Clear();
                UsedLogLevelsWritable.Clear();
                UsedTagsWritable.Clear();
                UsedApplicationNamesWritable.Clear();
                UsedProcessNamesWritable.Clear();
                UsedProcessIdsWritable.Clear();
            }
        }