Beispiel #1
0
        public void ProcessLogMessage(LogMessage logMsg)
        {
            // Check 1st in the global LoggerPath/Logger dictionary
            LoggerItem logger;

            logMsg.CheckNull();

            if (!_fullPathLoggers.TryGetValue(logMsg.LoggerName, out logger))
            {
                // Not found, create one
                logger = RootLoggerItem.GetOrCreateLogger(logMsg.LoggerName);
            }
            if (logger == null)
            {
                throw new Exception("No Logger for this Log Message.");
            }

            var item = logger.AddLogMessage(logMsg);

            lock (LogManager.Instance.dataLocker)
            {
                _allLogMessageItems.Enqueue(item);
                if (item.Enabled && !LogManager.Instance.PauseRefreshNewMessages)
                {
                    _dataSource.Enqueue(item);
                }

                // 只在 TryEnsureVisibleForSuitableItems 函数中调用 DequeueMoreThanMaxCount, 防止新增消息的时候, 影响listview的index指向的实际行.
                //DequeueMoreThanMaxCount();
            }
        }
Beispiel #2
0
        public void ProcessLogMessage(LogMessage logMsg)
        {
            // Check 1st in the global LoggerPath/Logger dictionary
            LoggerItem logger;

            logMsg.CheckNull();

            if (!_fullPathLoggers.TryGetValue(logMsg.LoggerName, out logger))
            {
                // Not found, create one
                logger = RootLoggerItem.GetOrCreateLogger(logMsg.LoggerName);
            }
            if (logger == null)
            {
                throw new Exception("No Logger for this Log Message.");
            }

            var item = logger.AddLogMessage(logMsg);

            lock (LogManager.Instance.dataLocker)
            {
                _allLogMessageItems.Enqueue(item);
                if (item.Enabled && !LogManager.Instance.PauseRefreshNewMessages)
                {
                    _dataSource.Enqueue(item);
                }

                var maxCount = Settings.UserSettings.Instance.MessageCycleCount;
                if (maxCount > 0)
                {
                    while (_allLogMessageItems.Count > maxCount)
                    {
                        var tobeRemoveItem = _allLogMessageItems[0];
                        _allLogMessageItems.Dequeue();
                        if (_dataSource.Count > 0 &&
                            !LogManager.Instance.PauseRefreshNewMessages
                            )
                        {
                            //remove all messages which ArrivedId <= tobeRemoveItem's ArrivedId.
                            while (_dataSource.Peek().Message.ArrivedId <= tobeRemoveItem.Message.ArrivedId)
                            {
                                _dataSource.Dequeue();
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public void ProcessLogMessage(LogMessage logMsg)
        {
            // Check 1st in the global LoggerPath/Logger dictionary
            LoggerItem logger;

            if (!_fullPathLoggers.TryGetValue(logMsg.LoggerName, out logger))
            {
                // Not found, create one
                logger = RootLoggerItem.GetOrCreateLogger(logMsg.LoggerName);
            }
            if (logger == null)
            {
                throw new Exception("No Logger for this Log Message.");
            }

            logger.AddLogMessage(logMsg);
        }