Skip to content

Instantly share code, notes, and snippets.

@nmackenzie
Last active December 20, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmackenzie/6181359 to your computer and use it in GitHub Desktop.
Save nmackenzie/6181359 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
[EventSource(Name = "MyDomain-MyEventSource")]
public class MyEventSource : EventSource
{
public class Keywords
{
public const EventKeywords Database = (EventKeywords)1;
public const EventKeywords ExternalApi = (EventKeywords)2;
}
public class Tasks
{
public const EventTask Timing = (EventTask)1;
}
[Event(1,
Message = "Method entry: {0}",
Level = EventLevel.Verbose)]
internal void MethodEntry(String message)
{
if (IsEnabled()) WriteEvent(1, message);
}
[Event(2,
Message = "External call to {0}/{1} - TimeSpan: {2}",
Level = EventLevel.Informational,
Keywords = Keywords.ExternalApi,
Task=Tasks.Timing)]
internal void ApiTiming(String apiName, String apiOperation, Int64 elapsedTimeMilliSeconds)
{
if (IsEnabled()) WriteEvent(2, apiName, apiOperation, elapsedTimeMilliSeconds);
}
[Event(3,
Message = "Invalid configuration entry: {0}",
Level = EventLevel.Warning)]
internal void MissingConfigurationEntry(String entryName)
{
if (IsEnabled()) WriteEvent(3, entryName);
}
public static readonly MyEventSource Log = new MyEventSource();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment