• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Tracing.EventSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: WriteEventCore

        protected unsafe void WriteEventCore(int eventId, int eventDataCount, EventSource.EventData* data)
        {
            if (m_eventData != null)
            {
                if (m_eventData[eventId].EnabledForETW)
                {
                    EventProvider.EventData* dataDescrs = stackalloc EventProvider.EventData[eventDataCount];
                    if (eventDataCount <= 0)
                    {
                        // EventWrite expects NULL if dataDescrs is zero.
                        // You cannot pass a ptr to an empty array.
                        dataDescrs = (EventProvider.EventData*)IntPtr.Zero;
                    }

                    for (int i = 0; i < eventDataCount; i++)
                    {
                        dataDescrs[i].Size = (uint)data[i].Size;
                        dataDescrs[i].Ptr = (ulong)(data[i].DataPointer.ToInt64());
                        dataDescrs[i].Reserved = 0;
                    }

                    if (!m_provider.WriteEvent(ref m_eventData[eventId].Descriptor, eventDataCount, (IntPtr)dataDescrs) && m_throwOnEventWriteErrors)
                        throw new EventSourceException();
                }

                if (m_Dispatchers != null && m_eventData[eventId].EnabledForAnyListener)
                {
                    object[] args = new object[eventDataCount];

                    for (int i = 0; i < eventDataCount; i++)
                    {
                        args[i] = DecodeObject(eventId, i, data[i].Size, data[i].DataPointer);
                    }

                    WriteToAllListeners(eventId, args);
                }
            }
        }
开发者ID:AndreGleichner,项目名称:corefx,代码行数:38,代码来源:EventProviderBase.cs


示例17: EventWrittenEventArgs

 internal EventWrittenEventArgs(EventSource eventSource)
 {
     m_eventSource = eventSource;
 }
开发者ID:AndreGleichner,项目名称:corefx,代码行数:4,代码来源:EventProviderBase.cs


示例18: EventCommandEventArgs

 internal EventCommandEventArgs(EventCommand command, IDictionary<string, string> arguments, EventSource eventSource, EventDispatcher dispatcher)
 {
     this.Command = command;
     this.Arguments = arguments;
     this.eventSource = eventSource;
     this.dispatcher = dispatcher;
 }
开发者ID:AndreGleichner,项目名称:corefx,代码行数:7,代码来源:EventProviderBase.cs


示例19: AddEventSource

        /// <summary>
        /// This routine adds newEventSource to the global list of eventSources, it also assigns the
        /// ID to the eventSource (which is simply the oridinal in the global list).
        /// 
        /// EventSources currently do not pro-actively remove themselves from this list. Instead
        /// when eventSources's are GCed, the weak handle in this list naturally gets nulled, and
        /// we will reuse the slot. Today this list never shrinks (but we do reuse entries
        /// that are in the list). This seems OK since the expectation is that EventSources
        /// tend to live for the lifetime of the appdomain anyway (they tend to be used in
        /// global variables).
        /// </summary>
        /// <param name="newEventSource"></param>
        internal static void AddEventSource(EventSource newEventSource)
        {
            lock (EventListenersLock)
            {
                if (s_EventSources == null)
                    s_EventSources = new List<WeakReference>(2);

                // Periodically search the list for existing entries to reuse, this avoids
                // unbounded memory use if we keep recycling eventSources (an unlikely thing). 
                int newIndex = -1;
                if (s_EventSources.Count % 64 == 63)   // on every block of 64, fill up the block before continuing
                {
                    int i = s_EventSources.Count;      // Work from the top down. 
                    while (0 < i)
                    {
                        --i;
                        WeakReference weakRef = s_EventSources[i];
                        if (!weakRef.IsAlive)
                        {
                            newIndex = i;
                            weakRef.Target = newEventSource;
                            break;
                        }
                    }
                }
                if (newIndex < 0)
                {
                    newIndex = s_EventSources.Count;
                    s_EventSources.Add(new WeakReference(newEventSource));
                }
                newEventSource.m_id = newIndex;

                // Add every existing dispatcher to the new EventSource
                for (EventListener listener = s_Listeners; listener != null; listener = listener.m_Next)
                    newEventSource.AddListener(listener);

                Validate();
            }
        }
开发者ID:AndreGleichner,项目名称:corefx,代码行数:51,代码来源:EventProviderBase.cs


示例20: SendCommand

        /// <summary>
        /// Send a command to a particular EventSource identified by 'eventSource'
        /// 
        /// Calling this routine simply forwards the command to the EventSource.OnEventCommand
        /// callback.  What the EventSource does with the command and its arguments are from that point
        /// EventSource-specific.  
        /// 
        /// The eventSource is passed the EventListener that issued the command along with the command and
        /// arguments.  The contract is that to the extent possible the eventSource should not affect other
        /// EventListeners (eg filtering events), however sometimes this simply is not possible (if the
        /// command was to provoke a GC, or a System flush etc).   
        /// </summary>
        public static void SendCommand(EventSource eventSource, EventCommand command, IDictionary<string, string> commandArguments)
        {
            if (eventSource == null)
                throw new ArgumentNullException(nameof(eventSource));

            // User-defined EventCommands should not conflict with the reserved commands.
            if ((int)command <= (int)EventCommand.Update && (int)command != (int)EventCommand.SendManifest)
                throw new ArgumentException(SR.ArgumentOutOfRange_NeedPosNum, nameof(command));

            eventSource.SendCommand(null, command, true, EventLevel.LogAlways, EventKeywords.None, commandArguments);
        }
开发者ID:AndreGleichner,项目名称:corefx,代码行数:23,代码来源:EventProviderBase.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DirectoryServices.DirectoryEntry类代码示例发布时间:2022-05-26
下一篇:
C# SymbolStore.SymbolToken类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap