Ejemplo n.º 1
0
 public void AddMessage(Message message)
 {
     lock (_messages)
     {
         _messages.Add(message);
     }
 }
Ejemplo n.º 2
0
 public void DequeueMessages(Message[] messages)
 {
     lock (_messages)
     {
         foreach (var message in messages)
         {
             _messages.Remove(message);
         }
     }
 }
Ejemplo n.º 3
0
 public void WriteMessage(Message message)
 {
     foreach (var outputPipe in _configurationContainer.Configuration.OutputPipes)
     {
         if (outputPipe.BufferMaximumKeepTime == TimeSpan.Zero)
         {
             outputPipe.OutputEngine.SaveMessages(message);
         }
         else
         {
             outputPipe.Queue.AddMessage(message);
         }
     }
 }
Ejemplo n.º 4
0
        public Message CreateMessage(
            Exception exception, StackFrame stackFrame, Level level, string format, params object[] args)
        {
            var message = new Message
            {
                DateTimeOffset = DateTimeOffset.Now,
                Format = format,
                FormatArguments = args,
                Level = level
            };

            if (stackFrame != null)
            {
                message.FileNumber = (uint)stackFrame.GetFileLineNumber();
                message.FileName = stackFrame.GetFileName();
                var method = stackFrame.GetMethod();
                message.OriginMethod = method.Name;
                var declaringType = stackFrame.GetMethod().DeclaringType;
                if (declaringType != null)
                {
                    message.OriginNamespace = declaringType.FullName;
                }
            }

            if (exception != null)
            {
                message.ExceptionMessage = exception.Message;
                message.ExceptionStackTrace = exception.StackTrace;
            }

            foreach (var messageModifier in _messageModifiers)
            {
                messageModifier.ModifyMessage(message);
            }

            return message;
        }