Example #1
0
        public void CopyTo(CyclicBuffer <T> destination)
        {
            int toCopy   = Math.Min(Count, destination.Capacity);
            int startPos = Count - 1 - toCopy;

            for (int i = startPos; i < Count; ++i)
            {
                destination.AddAndRemoveLast(this[i]);
            }
        }
Example #2
0
        private void ProcessNewEvents()
        {
            List <LogEvent> logEventsToProcess = null;

            lock (this)
            {
                if (_haveNewEvents)
                {
                    logEventsToProcess = _newEvents;
                    _newEvents         = new List <LogEvent>();
                    _haveNewEvents     = false;
                }
            }

            if (logEventsToProcess != null)
            {
                logger.Info("Processing start {0} items.", logEventsToProcess.Count);
                int t0 = Environment.TickCount;
                foreach (LogEvent logEvent in logEventsToProcess)
                {
                    LogEvent removedEvent = _bufferedEvents.AddAndRemoveLast(logEvent);
                    if (removedEvent != null)
                    {
                        _filteredEvents.Remove(removedEvent);
                    }

                    if (TryFilters(logEvent))
                    {
                        _filteredEvents.Add(logEvent);
                    }

                    _totalEvents++;

                    for (int i = 0; i < Columns.Count; ++i)
                    {
                        if (Columns[i].Grouping != LogColumnGrouping.None)
                        {
                            TabPanel.ApplyGrouping(Columns[i], logEvent[i]);
                        }
                    }

                    /*
                     * // LogEventAttributeToNode(logEvent["Level"], _levelsTreeNode, _level2NodeCache, (char)0);
                     * LogEventAttributeToNode((string)logEvent["Logger"], _loggersTreeNode, _logger2NodeCache, '.');
                     * LogEventAttributeToNode((string)logEvent["SourceAssembly"], _assembliesTreeNode, _assembly2NodeCache, (char)0);
                     * TreeNode node = LogEventAttributeToNode((string)logEvent["SourceType"], _classesTreeNode, _class2NodeCache, '.');
                     * // LogEventAttributeToNode(logEvent.SourceMethod, node,
                     * LogEventAttributeToNode((string)logEvent["Thread"], _threadsTreeNode, _thread2NodeCache, (char)0);
                     * LogEventAttributeToNode((string)logEvent["SourceApplication"], _applicationsTreeNode, _application2NodeCache, (char)0);
                     * LogEventAttributeToNode((string)logEvent["SourceMachine"], _machinesTreeNode, _machine2NodeCache, (char)0);
                     * LogEventAttributeToNode((string)logEvent["SourceFile"], _filesTreeNode, _file2NodeCache, (char)'\\');
                     * */
                }
                int t1  = Environment.TickCount;
                int ips = -1;
                if (t1 > t0)
                {
                    ips = 1000 * logEventsToProcess.Count / (t1 - t0);
                }
                logger.Info("Processing finished {0} items. Total {1} ips: {2} time: {3}.", _filteredEvents.Count, logEventsToProcess.Count, ips, t1 - t0);
                TabPanel.listViewLogMessages.VirtualListSize = _filteredEvents.Count;
                TabPanel.listViewLogMessages.Invalidate();
                UpdateStatusBar();
            }
        }