コード例 #1
0
ファイル: Log.cs プロジェクト: onesimoh/Andamio
        /// <summary>
        /// Contextual log, important messages and traces.
        /// </summary>
        /// <returns>Log Entries</returns>
        public LogEntries Contextual()
        {
            int index = 0;
            LogEntries logEntries = new LogEntries();
            while (logEntries.Count < 200)
            {
                if (index >= Entries.Count) break;
                LogEntry logEntry = Entries[index++];

                switch (logEntry.EventType)
                {
                    case LogEventType.Information:
                    case LogEventType.Warning:
                        logEntries.Add(logEntry);
                        break;
                    case LogEventType.Error:
                    case LogEventType.Critical:
                        logEntries.AddRange(Entries.Skip(index - 10).Take(10).Where(match => !logEntries.Contains(match)));
                        logEntries.AddRange(Entries.Skip(index).Take(10));
                        index += 10;
                        break;
                    case LogEventType.Trace:
                    default:
                        continue;
                }
            }

            return logEntries;
        }