/// <summary> /// Trace the specified message. /// </summary> /// <param name="message">Message.</param> /// <remarks>ITraceService implementation</remarks> public void Trace(Message message) { // Console.WriteLine("{0}: TraceService: Writing: {1}", DateTime.Now, message.ToString()); byte[] buf = Encoding.ASCII.GetBytes(string.Concat(message.ToString(), "\n")); _file.Write(buf, 0, buf.Length); _file.Flush(); }
/// <summary> /// Initializes a new instance of the <see cref="TraceService.MessageSurrogated"/> class. /// </summary> /// <param name="message">Message.</param> public MessageSurrogated(Message message) { Time = message.Time; Source = message.Source; SourceName = message.Source.Name; Level = message.Level; Id = message.Id; Category = message.Category; Description = message.Description; Data = message.Data; DataValues = new object[Data.Count]; message.Data.Values.CopyTo(DataValues, 0); Stack = message.Stack; Domain = message.Domain; Process = message.Process; ProcessId = message.Process.Id; }
/// <summary> /// Trace the specified message. /// </summary> /// <param name="message">Message.</param> public abstract void Trace(Message message);
/// <summary> /// Log the specified message. /// </summary> /// <param name="message">Message.</param> private void Log(Message message) { _messageQueue.Enqueue(message); }
/// <summary> /// Logs the exception. /// </summary> /// <param name="ex">Ex.</param> /// <param name="data">Data.</param> public void LogException(Exception ex, params object[] data) { Message msg = new Message(this, data) { Level = MessageLevel.Error, Category = "Execution", Description = ex.ToString() //.GetType().FullName }; Log(msg); }
/// <summary> /// Logs the method call. /// </summary> /// <param name="level">Level.</param> /// <param name="data">Data.</param> public void LogMethodCall(MessageLevel level, params object[] data) { StackFrame sf = new StackFrame(1, true); MethodBase method = sf.GetMethod(); StringBuilder sb = new StringBuilder(256); sb.AppendFormat("{0}.{1}", method.DeclaringType.FullName, method.Name); if (method.ContainsGenericParameters) { sb.Append("<"); foreach (Type TParam in method.GetGenericArguments()) sb.AppendFormat("{0}, ", TParam.FullName); sb.Remove(sb.Length - 2, 2); sb.Append(">"); } sb.Append("("); foreach (ParameterInfo pi in sf.GetMethod().GetParameters()) sb.AppendFormat("{0} {1}, ", pi.ParameterType.FullName, pi.Name); sb.Remove(sb.Length - 2, 2); sb.Append(")"); Message msg = new Message(this, data) { Level = level, Category = "Execution", Description = "Method Call" }; Log(msg); }
/// <summary> /// Log the specified level, category, description and data. /// </summary> /// <param name="level">Level.</param> /// <param name="data">Data.</param> public void Log(MessageLevel level, params object[] data) { Message msg = new Message(this, data) { Level = level }; Log(msg); }
/// <summary> /// Log the specified level, category, description and data. /// </summary> /// <param name="level">Level.</param> /// <param name="description">Description.</param> /// <param name="data">Data.</param> public void Log(MessageLevel level, string description, params object[] data) { Message msg = new Message(this, data) { Level = level, Description = description }; Log(msg); }
/// <summary> /// Trace the specified message. /// </summary> /// <param name="message">Message.</param> /// <remarks>Listener implementation</remarks> public override void Trace(Message message) { Proxy.Trace(message); }
/// <summary> /// Trace the specified message. /// </summary> /// <param name="message">Message.</param> /// <remarks>Listener implementation</remarks> public override void Trace(Message message) { Console.WriteLine(message.ToString()); }
/// <summary> /// Trace the specified message. /// </summary> /// <param name="message">Message.</param> /// <remarks>Listener implementation</remarks> public override void Trace(Message message) { Log.Add(message); }