Пример #1
0
 /// <summary>
 ///     String serialization of <see cref="TraceEventData" />.
 /// </summary>
 /// <returns>A string representing the <see cref="TraceEventData" /> instace.</returns>
 /// <remarks>
 ///     To help visualization in basic TraceListener like the DefaultTraceListener (Visual Studio, DebugViewer).
 /// </remarks>
 public override string ToString()
 {
     if (TraceCategory == TraceCategory.Performance)
     {
         return(string.Format(CultureInfo.CurrentCulture, "{0}-{1}|{2}-{3}|{4}|{5}|{6}|{7}ms",
                              TraceSourceType.ToString(), TraceSourceName,
                              TraceEventType.ToString(), TraceEventName,
                              TraceCategory,
                              CreationDate,
                              Message,
                              ElapsedTime));
     }
     if (TraceCategory == TraceCategory.Error || TraceCategory == TraceCategory.Warning && RawException != null)
     {
         return(string.Format(CultureInfo.CurrentCulture, "{0}-{1}|{2}-{3}|{4}|{5}|{6}|{7}|{8}|{9}",
                              TraceSourceType.ToString(), TraceSourceName,
                              TraceEventType.ToString(), TraceEventName,
                              TraceCategory,
                              CreationDate,
                              Message,
                              ExceptionType,
                              RawException,
                              StackTrace));
     }
     return(string.Format(CultureInfo.CurrentCulture, "{0}-{1}|{2}-{3}|{4}|{5}|{6}",
                          TraceSourceType.ToString(), TraceSourceName,
                          TraceEventType.ToString(), TraceEventName,
                          TraceCategory,
                          CreationDate,
                          Message));
 }
Пример #2
0
 /// <summary>
 ///     Creates a trace source of the specified trace source type with the specified trace source name.
 /// </summary>
 /// <param name="traceSourceType">The trace source type.</param>
 /// <param name="traceSourceName">The instance name of the trace source type.</param>
 public void SetSource(TraceSourceType traceSourceType, string traceSourceName)
 {
     if (_traceSource != null)
     {
         return;
     }
     _traceSourceName = traceSourceName;
     _traceSourceType = traceSourceType;
     _traceSource     = new TraceSource(traceSourceType.ToString());
 }