本文整理汇总了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);
}
示例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();
}
}
示例3: WaitForEnable
public void WaitForEnable(EventSource logger)
{
if (!SpinWait.SpinUntil(() => logger.IsEnabled(), TimeSpan.FromSeconds(10)))
{
throw new InvalidOperationException("EventSource not enabled after 5 seconds");
}
}
示例4: EnableSourceIfMatch
private void EnableSourceIfMatch(EventSource source)
{
if (_targetSourceName.ContainsKey(source.Name))
{
EnableEvents(source, _level);
}
}
示例5: EnableSourceIfMatch
private void EnableSourceIfMatch(EventSource source)
{
if (source.Name.Equals(_targetSourceName) ||
source.Guid.Equals(_targetSourceGuid))
{
EnableEvents(source, _level);
}
}
示例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);
}
}
示例7: OnEventSourceCreated
protected override void OnEventSourceCreated(EventSource eventSource)
{
base.OnEventSourceCreated(eventSource);
if (eventSource.Name.Equals(Constants.LogSourceName))
{
this.EnableEvents(eventSource, EventLevel.Verbose);
}
}
示例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);
}
}
示例9: EventProviderSubscription
public EventProviderSubscription(EventSource source)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
this.Source = source;
}
示例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);
}
示例11: OnEventSourceCreated
protected override void OnEventSourceCreated(EventSource eventSource)
{
if (_providers == null)
{
_eventSourcesToEnable.Add(eventSource);
}
if (IsIntendedEventSource(eventSource))
{
this.EnableEvents(eventSource, EventLevel.LogAlways);
}
}
示例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");
}
示例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];
}
示例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);
}
示例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
{ }
}
}
}