当前位置: 首页>>代码示例>>C#>>正文


C# Tracing.EventSource类代码示例

本文整理汇总了C#中System.Diagnostics.Tracing.EventSource的典型用法代码示例。如果您正苦于以下问题:C# EventSource类的具体用法?C# EventSource怎么用?C# EventSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EventSource类属于System.Diagnostics.Tracing命名空间,在下文中一共展示了EventSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EnableTimer

 internal void EnableTimer(EventSource eventSource, int pollingTime)
 {
     FilteringOptions options = new FilteringOptions();
     options.Args = new Dictionary<string, string>();
     options.Args.Add("EventCounterIntervalSec", pollingTime.ToString());
     EventSourceCommand(eventSource.Name, EventCommand.Enable, options);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:7,代码来源:Listeners.cs

示例2: Test_BadTypes_Manifest

        private void Test_BadTypes_Manifest(EventSource source)
        {
            try
            {
                var listener = new EventListenerListener();

                var events = new List<Event>();
                Debug.WriteLine("Adding delegate to onevent");
                listener.OnEvent = delegate (Event data) { events.Add(data); };

                listener.EventSourceCommand(source.Name, EventCommand.Enable);

                listener.Dispose();

                // Confirm that we get exactly one event from this whole process, that has the error message we expect.  
                Assert.Equal(events.Count, 1);
                Event _event = events[0];
                Assert.Equal("EventSourceMessage", _event.EventName);
                string message = _event.PayloadString(0, "message");
                // expected message: "ERROR: Exception in Command Processing for EventSource BadEventSource_Bad_Type_ByteArray: Unsupported type Byte[] in event source. "
                Assert.True(Regex.IsMatch(message, "Unsupported type"));
            }
            finally
            {
                source.Dispose();
            }
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:27,代码来源:TestsUserErrors.cs

示例3: WaitForEnable

 public void WaitForEnable(EventSource logger)
 {
     if (!SpinWait.SpinUntil(() => logger.IsEnabled(), TimeSpan.FromSeconds(10)))
     {
         throw new InvalidOperationException("EventSource not enabled after 5 seconds");
     }
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:7,代码来源:Listeners.cs

示例4: EnableSourceIfMatch

 private void EnableSourceIfMatch(EventSource source)
 {
     if (_targetSourceName.ContainsKey(source.Name))
     {
         EnableEvents(source, _level);
     }
 }
开发者ID:roncain,项目名称:wcf,代码行数:7,代码来源:TestEventListener.cs

示例5: EnableSourceIfMatch

 private void EnableSourceIfMatch(EventSource source)
 {
     if (source.Name.Equals(_targetSourceName) || 
         source.Guid.Equals(_targetSourceGuid))
     {
         EnableEvents(source, _level);
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:TestEventListener.cs

示例6: OnEventSourceCreated

        /// <summary>Called for all existing event sources when the event listener is created and when a new event
        /// source is attached to the listener. Enables log sources to the appropriate event level.</summary>
        /// <param name="eventSource">The event source.</param>
        protected override void OnEventSourceCreated(EventSource eventSource)
        {
            var log = eventSource as Log;

            if (log != null)
            {
                this.EnableEvents(log, this.eventLevel);
            }
        }
开发者ID:Lawo,项目名称:ember-plus-sharp,代码行数:12,代码来源:LogListener.cs

示例7: OnEventSourceCreated

        protected override void OnEventSourceCreated(EventSource eventSource)
        {
            base.OnEventSourceCreated(eventSource);

            if (eventSource.Name.Equals(Constants.LogSourceName))
            {
                this.EnableEvents(eventSource, EventLevel.Verbose);
            }
        }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:9,代码来源:TestLogListener.cs

示例8: OnEventSourceCreated

 protected override void OnEventSourceCreated(EventSource eventSource)
 {
     // Check for null because this method is called by the base class constror before we can initialize it
     Action<EventSource> callback = this.OnOnEventSourceCreated;
     if (callback != null)
     {
         callback(eventSource);
     }
 }
开发者ID:bitstadium,项目名称:HockeySDK-Windows,代码行数:9,代码来源:TestEventListener.cs

示例9: EventProviderSubscription

        public EventProviderSubscription(EventSource source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            this.Source = source;
        }
开发者ID:thestevemadden,项目名称:Microsoft.Diagnostics.Tracing.Logging,代码行数:9,代码来源:Logger.cs

示例10: OnEventSourceCreated

        /// <summary>
        /// Enables HTTP event source when EventSource is created. Called for all existing 
        /// event sources when the event listener is created and when a new event source is attached to the listener.
        /// </summary>
        protected override void OnEventSourceCreated(EventSource eventSource)
        {
            if (eventSource != null && eventSource.Name == FrameworkEventSourceName)
            {
                this.EnableEvents(eventSource, EventLevel.Informational, (EventKeywords)4);
                DependencyCollectorEventSource.Log.RemoteDependencyModuleVerbose("HttpEventListener initialized for event source:" + FrameworkEventSourceName);
            }

            base.OnEventSourceCreated(eventSource);
        }
开发者ID:Microsoft,项目名称:ApplicationInsights-dotnet-server,代码行数:14,代码来源:FrameworkHttpEventListener.cs

示例11: OnEventSourceCreated

            protected override void OnEventSourceCreated(EventSource eventSource)
            {
                if (_providers == null)
                {
                    _eventSourcesToEnable.Add(eventSource);
                }

                if (IsIntendedEventSource(eventSource))
                {
                    this.EnableEvents(eventSource, EventLevel.LogAlways);
                }
            }
开发者ID:yantang-msft,项目名称:LogstashNet,代码行数:12,代码来源:EtwEventSourceInput.cs

示例12: Test_EventSource_Traits_Dynamic

 public void Test_EventSource_Traits_Dynamic()
 {
     TestUtilities.CheckNoEventSourcesRunning("Start");
     using (var mySource = new EventSource("DynamicEventSourceWithTraits", EventSourceSettings.Default,
         "MyTrait", "MyTraitValue",
         "ETW_GROUP", "{4f50731a-89cf-4782-b3e0-dce8c90476ba}"))
     {
         // By default we are self-describing.  
         Assert.Equal(mySource.Settings, EventSourceSettings.EtwSelfDescribingEventFormat);
         Assert.Equal(mySource.GetTrait("MyTrait"), "MyTraitValue");
         Assert.Equal(mySource.GetTrait("ETW_GROUP"), "{4f50731a-89cf-4782-b3e0-dce8c90476ba}");
     }
     TestUtilities.CheckNoEventSourcesRunning("Stop");
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:14,代码来源:TestsTraits.cs

示例13: GetSchema

        /// <summary>
        /// Gets the <see cref="EventSchema"/> for the specified eventId and eventSource.
        /// </summary>
        /// <param name="eventId">The ID of the event.</param>
        /// <param name="eventSource">The event source.</param>
        /// <returns>The EventSchema.</returns>
        public EventSchema GetSchema(int eventId, EventSource eventSource)
        {
            Guard.ArgumentNotNull(eventSource, "eventSource");

            IReadOnlyDictionary<int, EventSchema> events;

            if (!this.schemas.TryGetValue(eventSource.Guid, out events))
            {
                events = new ReadOnlyDictionary<int, EventSchema>(this.schemaReader.GetSchema(eventSource));
                this.schemas[eventSource.Guid] = events;
            }

            return events[eventId];
        }
开发者ID:guyzo,项目名称:semantic-logging,代码行数:20,代码来源:EventSourceSchemaCache.cs

示例14: OnEventSourceCreated

        protected override void OnEventSourceCreated(EventSource eventSource)
        {
            List<EventSource> tmp = _tmpEventSourceList;
            if (tmp != null)
            {
                lock (tmp)
                {
                    if (_tmpEventSourceList != null)
                    {
                        _tmpEventSourceList.Add(eventSource);
                        return;
                    }
                }
            }

            EnableSourceIfMatch(eventSource);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:17,代码来源:TestEventListener.cs

示例15: With2Listeners

        public static void With2Listeners(EventSource logger, Action<ObservableEventListener, ObservableEventListener> scenario)
        {
            using (var listener1 = new ObservableEventListener())
            using (var listener2 = new ObservableEventListener())
            {
                try
                {
                    scenario(listener1, listener2);
                }
                finally
                {
                    try
                    { listener1.DisableEvents(logger); }
                    catch
                    { }

                    try
                    { listener2.DisableEvents(logger); }
                    catch
                    { }
                }
            }
        }
开发者ID:calebjenkins,项目名称:semantic-logging,代码行数:23,代码来源:TestScenario.cs


注:本文中的System.Diagnostics.Tracing.EventSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。