public HttpNetTraceMessagePublishedEventArgs(int threadId, string source, HttpNetTraceLevel level, string message, Exception exception)
 {
     ThreadId  = threadId;
     Source    = source;
     Level     = level;
     Message   = message;
     Exception = exception;
 }
예제 #2
0
        private static void Publish(string source, HttpNetTraceLevel traceLevel, Exception exception, string message, params object[] parameters)
        {
            var handler = TraceMessagePublished;

            if (handler == null)
            {
                return;
            }

            if (parameters?.Length > 0)
            {
                try
                {
                    message = string.Format(message, parameters);
                }
                catch (Exception formatException)
                {
                    Error(nameof(HttpNetTrace), formatException, "Error while tracing message: " + message);
                    return;
                }
            }

            handler.Invoke(null, new HttpNetTraceMessagePublishedEventArgs(Environment.CurrentManagedThreadId, source, traceLevel, message, exception));
        }