示例#1
0
 public DefaultActionItem(Action <object> callback, object state, bool isLowPriority)
 {
     Fx.Assert(callback != null, "Shouldn't instantiate an object to wrap a null callback");
     base.LowPriority = isLowPriority;
     _callback        = callback;
     _state           = state;
     if (WaitCallbackActionItem.ShouldUseActivity)
     {
         _flowLegacyActivityId = true;
         _activityId           = EtwDiagnosticTrace.ActivityId;
     }
     if (Fx.Trace.IsEnd2EndActivityTracingEnabled)
     {
         _eventTraceActivity = EventTraceActivity.GetFromThreadOrCreate();
         if (TraceCore.ActionItemScheduledIsEnabled(Fx.Trace))
         {
             TraceCore.ActionItemScheduled(Fx.Trace, _eventTraceActivity);
         }
     }
 }
示例#2
0
        private TException TraceException <TException>(TException exception, string eventSource)
            where TException : Exception
        {
            string str;

            if (TraceCore.ThrowingExceptionIsEnabled(this.diagnosticTrace))
            {
                EtwDiagnosticTrace etwDiagnosticTrace = this.diagnosticTrace;
                string             str1 = eventSource;
                if (exception != null)
                {
                    str = exception.ToString();
                }
                else
                {
                    str = string.Empty;
                }
                TraceCore.ThrowingException(etwDiagnosticTrace, str1, str, exception);
            }
            this.BreakOnException(exception);
            return(exception);
        }
示例#3
0
        public void TraceHandledException(Exception exception, TraceEventType traceEventType)
        {
            switch (traceEventType)
            {
            case TraceEventType.Error:
                if (!TraceCore.HandledExceptionErrorIsEnabled(_diagnosticTrace))
                {
                    break;
                }
                TraceCore.HandledExceptionError(_diagnosticTrace, exception != null ? exception.ToString() : string.Empty, exception);
                break;

            case TraceEventType.Warning:
                if (!TraceCore.HandledExceptionWarningIsEnabled(_diagnosticTrace))
                {
                    break;
                }
                TraceCore.HandledExceptionWarning(_diagnosticTrace, exception != null ? exception.ToString() : string.Empty, exception);
                break;

            case TraceEventType.Verbose:
                if (!TraceCore.HandledExceptionVerboseIsEnabled(_diagnosticTrace))
                {
                    break;
                }
                TraceCore.HandledExceptionVerbose(_diagnosticTrace, exception != null ? exception.ToString() : string.Empty, exception);
                break;

            default:
                if (!TraceCore.HandledExceptionIsEnabled(_diagnosticTrace))
                {
                    break;
                }
                TraceCore.HandledException(_diagnosticTrace, exception != null ? exception.ToString() : string.Empty, exception);
                break;
            }
        }
示例#4
0
 private static void EnsureEventDescriptors()
 {
     if (TraceCore.eventDescriptorsCreated == null)
     {
         Monitor.Enter(TraceCore.syncLock);
         try
         {
             if (TraceCore.eventDescriptorsCreated == null)
             {
                 TraceCore.CreateEventDescriptors();
                 TraceCore.eventDescriptorsCreated = true;
             }
         }
         finally
         {
             Monitor.Exit(TraceCore.syncLock);
         }
         return;
     }
     else
     {
         return;
     }
 }
示例#5
0
            private void ChangeQuota(ref InternalBufferManager.PooledBufferManager.BufferPool bufferPool, int delta)
            {
                if (TraceCore.BufferPoolChangeQuotaIsEnabled(Fx.Trace))
                {
                    TraceCore.BufferPoolChangeQuota(Fx.Trace, bufferPool.BufferSize, delta);
                }
                InternalBufferManager.PooledBufferManager.BufferPool bufferPool1 = bufferPool;
                int limit = bufferPool1.Limit + delta;

                InternalBufferManager.PooledBufferManager.BufferPool bufferPool2 = InternalBufferManager.PooledBufferManager.BufferPool.CreatePool(bufferPool1.BufferSize, limit);
                for (int i = 0; i < limit; i++)
                {
                    byte[] numArray = bufferPool1.Take();
                    if (numArray == null)
                    {
                        break;
                    }
                    bufferPool2.Return(numArray);
                    bufferPool2.IncrementCount();
                }
                InternalBufferManager.PooledBufferManager bufferSize = this;
                bufferSize.remainingMemory = bufferSize.remainingMemory - (long)(bufferPool1.BufferSize * delta);
                bufferPool = bufferPool2;
            }
示例#6
0
            private void ChangeQuota(ref BufferPool bufferPool, int delta)
            {
                if (TraceCore.BufferPoolChangeQuotaIsEnabled(Fx.Trace))
                {
                    TraceCore.BufferPoolChangeQuota(Fx.Trace, bufferPool.BufferSize, delta);
                }

                BufferPool oldBufferPool = bufferPool;
                int        newLimit      = oldBufferPool.Limit + delta;
                BufferPool newBufferPool = BufferPool.CreatePool(oldBufferPool.BufferSize, newLimit);

                for (int i = 0; i < newLimit; i++)
                {
                    byte[] buffer = oldBufferPool.Take();
                    if (buffer == null)
                    {
                        break;
                    }
                    newBufferPool.Return(buffer);
                    newBufferPool.IncrementCount();
                }
                _remainingMemory -= oldBufferPool.BufferSize * delta;
                bufferPool        = newBufferPool;
            }
示例#7
0
 public void AsWarning(Exception exception)
 {
     TraceCore.HandledExceptionWarning(Fx.Trace, exception);
 }
示例#8
0
 public void AsInformation(Exception exception)
 {
     TraceCore.HandledException(Fx.Trace, exception);
 }
示例#9
0
 public void TraceUnhandledException(Exception exception)
 {
     TraceCore.UnhandledException(Fx.Trace, exception);
 }
示例#10
0
 public void AsWarning(Exception exception)
 {
     //Traces a warning trace message
     TraceCore.HandledExceptionWarning(this.diagnosticTrace, exception != null ? exception.ToString() : string.Empty, exception);
 }
示例#11
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=57403, Level=warning, Channel=Debug
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool TraceCodeEventLogWarningIsEnabled(EtwDiagnosticTrace trace)
 {
     return(trace.ShouldTrace(TraceEventLevel.Warning) || TraceCore.IsEtwEventEnabled(trace, 9));
 }
示例#12
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=133, Level=verbose, Channel=Debug
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool ActionItemScheduledIsEnabled(EtwDiagnosticTrace trace)
 {
     return(TraceCore.IsEtwEventEnabled(trace, 13));
 }
示例#13
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=131, Level=verbose, Channel=Debug
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool BufferPoolAllocationIsEnabled(EtwDiagnosticTrace trace)
 {
     return(TraceCore.IsEtwEventEnabled(trace, 11));
 }
示例#14
0
        public void TraceEtwException(Exception exception, TraceEventType eventType)
        {
            string         str;
            string         empty;
            string         str1;
            TraceEventType traceEventType = eventType;

            switch (traceEventType)
            {
            case TraceEventType.Critical:
            {
                if (!TraceCore.UnhandledExceptionIsEnabled(this.diagnosticTrace))
                {
                    break;
                }
                EtwDiagnosticTrace etwDiagnosticTrace = this.diagnosticTrace;
                if (exception != null)
                {
                    str = exception.ToString();
                }
                else
                {
                    str = string.Empty;
                }
                TraceCore.EtwUnhandledException(etwDiagnosticTrace, str, exception);
                return;
            }

            case TraceEventType.Error:
            case TraceEventType.Warning:
            {
                if (!TraceCore.ThrowingExceptionIsEnabled(this.diagnosticTrace))
                {
                    break;
                }
                EtwDiagnosticTrace etwDiagnosticTrace1 = this.diagnosticTrace;
                string             str2 = this.eventSourceName;
                if (exception != null)
                {
                    empty = exception.ToString();
                }
                else
                {
                    empty = string.Empty;
                }
                TraceCore.ThrowingEtwException(etwDiagnosticTrace1, str2, empty, exception);
                return;
            }

            case TraceEventType.Critical | TraceEventType.Error:
            {
                if (!TraceCore.ThrowingExceptionVerboseIsEnabled(this.diagnosticTrace))
                {
                    break;
                }
                EtwDiagnosticTrace etwDiagnosticTrace2 = this.diagnosticTrace;
                string             str3 = this.eventSourceName;
                if (exception != null)
                {
                    str1 = exception.ToString();
                }
                else
                {
                    str1 = string.Empty;
                }
                TraceCore.ThrowingEtwExceptionVerbose(etwDiagnosticTrace2, str3, str1, exception);
                break;
            }

            default:
            {
                if (!TraceCore.ThrowingExceptionVerboseIsEnabled(this.diagnosticTrace))
                {
                    break;
                }
                EtwDiagnosticTrace etwDiagnosticTrace2 = this.diagnosticTrace;
                string             str3 = this.eventSourceName;
                if (exception != null)
                {
                    str1 = exception.ToString();
                }
                else
                {
                    str1 = string.Empty;
                }
                TraceCore.ThrowingEtwExceptionVerbose(etwDiagnosticTrace2, str3, str1, exception);
                break;
            }
            }
        }
示例#15
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=57394, Level=informational, Channel=Analytic
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool HandledExceptionIsEnabled(EtwDiagnosticTrace trace)
 {
     return(trace.ShouldTrace(TraceEventLevel.Informational) || TraceCore.IsEtwEventEnabled(trace, 1));
 }
示例#16
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=57407, Level=verbose, Channel=Analytic
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool ThrowingExceptionVerboseIsEnabled(EtwDiagnosticTrace trace)
 {
     return(trace.ShouldTrace(TraceEventLevel.Verbose) || TraceCore.IsEtwEventEnabled(trace, 20));
 }
示例#17
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=57393, Level=informational, Channel=Debug
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool AppDomainUnloadIsEnabled(EtwDiagnosticTrace trace)
 {
     return(trace.ShouldTrace(TraceEventLevel.Informational) || TraceCore.IsEtwEventEnabled(trace, 0));
 }
示例#18
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=57405, Level=error, Channel=Operational
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool HandledExceptionErrorIsEnabled(EtwDiagnosticTrace trace)
 {
     return(trace.ShouldTrace(TraceEventLevel.Error) || TraceCore.IsEtwEventEnabled(trace, 15));
 }
示例#19
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=57404, Level=warning, Channel=Analytic
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool HandledExceptionWarningIsEnabled(EtwDiagnosticTrace trace)
 {
     return(trace.ShouldTrace(TraceEventLevel.Warning) || TraceCore.IsEtwEventEnabled(trace, 10));
 }
示例#20
0
 private TException TraceException <TException>(TException exception, string eventSource) where TException : Exception
 {
     TraceCore.ThrowingException(Fx.Trace, eventSource, exception);
     this.BreakOnException(exception);
     return(exception);
 }
示例#21
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=57408, Level=critical, Channel=Operational
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool EtwUnhandledExceptionIsEnabled(EtwDiagnosticTrace trace)
 {
     return(TraceCore.IsEtwEventEnabled(trace, 17));
 }
示例#22
0
 public void TraceUnhandledException(Exception exception)
 {
     TraceCore.UnhandledException(_diagnosticTrace, exception != null ? exception.ToString() : string.Empty, exception);
 }
示例#23
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=132, Level=verbose, Channel=Debug
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool BufferPoolChangeQuotaIsEnabled(EtwDiagnosticTrace trace)
 {
     return(TraceCore.IsEtwEventEnabled(trace, 12));
 }
示例#24
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=57401, Level=informational, Channel=Debug
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool TraceCodeEventLogInfoIsEnabled(EtwDiagnosticTrace trace)
 {
     return(trace.ShouldTrace(TraceEventLevel.Informational) || TraceCore.IsEtwEventEnabled(trace, 7));
 }
示例#25
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=134, Level=verbose, Channel=Debug
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool ActionItemCallbackInvokedIsEnabled(EtwDiagnosticTrace trace)
 {
     return(TraceCore.IsEtwEventEnabled(trace, 14));
 }
示例#26
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=57402, Level=verbose, Channel=Debug
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool TraceCodeEventLogVerboseIsEnabled(EtwDiagnosticTrace trace)
 {
     return(trace.ShouldTrace(TraceEventLevel.Verbose) || TraceCore.IsEtwEventEnabled(trace, 8));
 }
示例#27
0
 /// <summary>
 /// Check if trace definition is enabled
 /// Event description ID=57409, Level=verbose, Channel=Analytic
 /// </summary>
 /// <param name="trace">The trace provider</param>
 internal static bool ThrowingEtwExceptionVerboseIsEnabled(EtwDiagnosticTrace trace)
 {
     return(TraceCore.IsEtwEventEnabled(trace, 19));
 }
示例#28
0
        public void TraceHandledException(Exception exception, TraceEventType traceEventType)
        {
            string         str;
            string         empty;
            string         str1;
            string         empty1;
            TraceEventType traceEventType1 = traceEventType;

            switch (traceEventType1)
            {
            case TraceEventType.Error:
            {
                if (!TraceCore.HandledExceptionErrorIsEnabled(this.diagnosticTrace))
                {
                    break;
                }
                EtwDiagnosticTrace etwDiagnosticTrace = this.diagnosticTrace;
                if (exception != null)
                {
                    str = exception.ToString();
                }
                else
                {
                    str = string.Empty;
                }
                TraceCore.HandledExceptionError(etwDiagnosticTrace, str, exception);
                return;
            }

            case TraceEventType.Critical | TraceEventType.Error:
            {
                if (!TraceCore.HandledExceptionIsEnabled(this.diagnosticTrace))
                {
                    break;
                }
                EtwDiagnosticTrace etwDiagnosticTrace1 = this.diagnosticTrace;
                if (exception != null)
                {
                    empty = exception.ToString();
                }
                else
                {
                    empty = string.Empty;
                }
                TraceCore.HandledException(etwDiagnosticTrace1, empty, exception);
                break;
            }

            case TraceEventType.Warning:
            {
                if (!TraceCore.HandledExceptionWarningIsEnabled(this.diagnosticTrace))
                {
                    break;
                }
                EtwDiagnosticTrace etwDiagnosticTrace2 = this.diagnosticTrace;
                if (exception != null)
                {
                    str1 = exception.ToString();
                }
                else
                {
                    str1 = string.Empty;
                }
                TraceCore.HandledExceptionWarning(etwDiagnosticTrace2, str1, exception);
                return;
            }

            default:
            {
                if (traceEventType1 == TraceEventType.Verbose)
                {
                    if (!TraceCore.HandledExceptionVerboseIsEnabled(this.diagnosticTrace))
                    {
                        break;
                    }
                    EtwDiagnosticTrace etwDiagnosticTrace3 = this.diagnosticTrace;
                    if (exception != null)
                    {
                        empty1 = exception.ToString();
                    }
                    else
                    {
                        empty1 = string.Empty;
                    }
                    TraceCore.HandledExceptionVerbose(etwDiagnosticTrace3, empty1, exception);
                    return;
                }
                else
                {
                    if (!TraceCore.HandledExceptionIsEnabled(this.diagnosticTrace))
                    {
                        break;
                    }
                    EtwDiagnosticTrace etwDiagnosticTrace1 = this.diagnosticTrace;
                    if (exception != null)
                    {
                        empty = exception.ToString();
                    }
                    else
                    {
                        empty = string.Empty;
                    }
                    TraceCore.HandledException(etwDiagnosticTrace1, empty, exception);
                    break;
                }
            }
            }
        }
示例#29
0
文件: Fx.cs 项目: dox0/DotNet471RS3
 public static Exception AssertAndThrowFatal(string description)
 {
     Fx.Assert(description);
     TraceCore.ShipAssertExceptionMessage(Trace, description);
     throw new FatalInternalException(description);
 }
示例#30
0
 public void AsInformation(Exception exception)
 {
     //Traces an informational trace message
     TraceCore.HandledException(this.diagnosticTrace, exception != null ? exception.ToString() : string.Empty, exception);
 }