Esempio n. 1
0
        public bool TryReadLine(out LogEvent[] logEvents)
        {
            if (messageQueue == null)
            {
                throw new ApplicationException("Sorry. You must Connect before ReadLine");
            }
            LoggingEvent msg = default(LoggingEvent);

            if (messageQueue.Count > 0)
            {
                logEvents = new LogEvent[messageQueue.Count];
                for (var i = 0; i < logEvents.Length; i++)
                {
                    if (messageQueue.Dequeue(out msg))
                    {
                        logEvents[i] = new LogEventDefault()
                        {
                            IsAudioAlarm = msg.Level >= Level.Error,
                            Color        = msg.Level >= Level.Error ? Color.Red : msg.Level >= Level.Warn ? Color.Yellow : Color.Empty,
                            Message      = msg.Level + ": " + msg.RenderedMessage,
                        };
                    }
                    else
                    {
                        break;
                    }
                }

                return(true);
            }
            logEvents = null;
            return(false);
        }
Esempio n. 2
0
        public LogEvent ReadLine()
        {
            if (messageQueue == null)
            {
                throw new ApplicationException("Sorry. You must Connect before ReadLine");
            }
            var msg = messageQueue.Dequeue();

            return(new LogEventDefault()
            {
                IsAudioAlarm = msg.Level >= Level.Error,
                MessageObject = msg.MessageObject
            });
        }