Exemplo n.º 1
0
        // for testing
        protected virtual void WriteMessage(LogMessageEntry2 message)
        {
            var console = OutStream;

            if (message.TimeStamp != null)
            {
                console.Write(message.TimeStamp);
            }

            if (message.LevelString != null)
            {
                console.Write(message.LevelString);
            }

            console.Write(message.Message);
            console.Flush();
        }
Exemplo n.º 2
0
        public virtual void EnqueueMessage(LogMessageEntry2 message)
        {
            if (!_messageQueue.IsAddingCompleted)
            {
                try
                {
                    _messageQueue.Add(message);
                    return;
                }
                catch (InvalidOperationException) { }
            }

            // Adding is completed so just log the message
            try
            {
                WriteMessage(message);
            }
            catch (Exception) { }
        }
Exemplo n.º 3
0
        public virtual void WriteMessage(LogLevel logLevel, string logName, int eventId, string message, Exception exception)
        {
            var logBuilder = _logBuilder;

            _logBuilder = null;

            if (logBuilder == null)
            {
                logBuilder = new StringBuilder();
            }

            LogMessageEntry2 entry2 = CreateDefaultLogMessage(logBuilder, logLevel, logName, eventId, message, exception);

            _queueProcessor.EnqueueMessage(entry2);

            logBuilder.Clear();
            if (logBuilder.Capacity > 1024)
            {
                logBuilder.Capacity = 1024;
            }
            _logBuilder = logBuilder;
        }