Exemple #1
0
    public void ProcessNewMessage(TraceMessage tMessage)
    {

      lock (ErrorHistory)
      {
        if (tMessage.Message is Exception)
        {
          lastErrorTime = DateTime.Now;
          lastErrorMessage = tMessage;
          //ErrorHistory.MessageList.Add(tMessage);
          //ErrorHistory.GlobalMessageIndex ++;

          //if (ErrorHistory.MessageList.Count > MaxErrorCapacity)
          //  ErrorHistory.ClearSomeMessages();
          ErrorHistory.AddNewMessage(tMessage);
        }

      }
      lock (MessageHistory)
      {
        //MessageHistory.MessageList.Add(tMessage);
        //MessageHistory.GlobalMessageIndex ++;
        MessageHistory.AddNewMessage(tMessage);
        _FileLog.WriteLine(ToXmlString(tMessage));

        //if (MessageHistory.MessageList.Count > MaxMessageCapacity)
        //  MessageHistory.ClearSomeMessages();
      }
    }
Exemple #2
0
 private static TraceMessage CreateDefaultTraceMessage(StackTrace trace)
 {
   TraceMessage message = new TraceMessage();
   if (Logger.IsTraceMessageWithMethod && trace.FrameCount >= 2)
     message.WithMethod(trace.GetFrame(1).GetMethod());
   if (Logger.IsTraceMessageWithThread)
     message.WithThread();
   return message;
 }
		public override void WriteLine(string message)
		{
      try
      {
        TraceMessage tMsg = new TraceMessage(message);
        log.ProcessNewMessage(tMsg);
      }
      catch
      {
      }
		}
		public override void Write(object o)
		{
      try
      {
        TraceMessage tMsg = o as TraceMessage;
        if (tMsg == null)
        {
          tMsg = new TraceMessage(o);
        }
				
        log.ProcessNewMessage(tMsg);
      }
      catch
      {
      }
		}
		public override void WriteLine(object o)
		{
      try
      {
        //TraceHlp2.TraceMessage tMsg;
        //if (o is TraceHlp2.TraceMessage)
        //{
        //  o = (TraceMessage)(o as TraceHlp2.TraceMessage);
        //}

        TraceMessage tMsg = o as TraceMessage;
        if (tMsg == null)
        {
          tMsg = new TraceMessage(o);
        }
        log.ProcessNewMessage(tMsg);
      
      }
      catch
      {
      }
		}	
Exemple #6
0
 static string ToXmlString(TraceMessage message)
 {
   StringBuilder builder = new StringBuilder();
   builder.AppendFormat("<Message time='{0}'>\r\n", TimeToString(message.MessageTime));
   if (message.IsWithThread)
   {
     if (message.ThreadName != null)
     {
       builder.AppendFormat("  <Thread name='{1}' id='{0}'/>\r\n", message.ThreadId,
         XmlEncode(message.ThreadName));
     }
     else
     {
       builder.AppendFormat("  <Thread id='{0}'/>\r\n", message.ThreadId);
     }
   }
   if (message.Method != null)
   {
     builder.AppendFormat("  <Method name='{0}.{1}' objectHash='{2}'/>\r\n",
       XmlEncode(message.Method.ReflectedType.FullName),
       XmlEncode(message.Method.Name),
       message.Hash);
   }
   if (message.Message != null)
   {
     builder.AppendFormat("  <Text>{0}</Text>\r\n", XmlEncode(Convert.ToString(message.Message)));
   }
   if (message.Args != null)
   {
     foreach (object arg in message.Args)
     {
       builder.AppendFormat("  <Arg>{0}</Arg>\r\n", XmlEncode(Convert.ToString(arg)));
     }
   }
   builder.Append("</Message>\r\n");
   return builder.ToString();
 }
Exemple #7
0
      public void AddNewMessage(TraceMessage tMessage)
      {
        messageList.Add(tMessage);
        GlobalMessageIndex++;

        if (messageList.Count > maxMessageCapacity)
          ClearSomeMessages();
      }