Skip to content

Instantly share code, notes, and snippets.

@SimonCropp
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save SimonCropp/10934590 to your computer and use it in GitHub Desktop.

Select an option

Save SimonCropp/10934590 to your computer and use it in GitHub Desktop.
public class RayGunSink : ILogEventSink
{
RaygunClient raygunClient = new RaygunClient("xxx=");
public Action<LogEvent> Action;
public void Emit(LogEvent logEvent)
{
if (logEvent.Level < LogEventLevel.Warning)
{
return;
}
var customData = new Dictionary<string, string>
{
{"Message", logEvent.RenderMessage()}
};
var tags = GetTags(logEvent).ToList();
raygunClient.Send(logEvent.Exception, tags, customData);
}
static IEnumerable<string> GetTags(LogEvent logEvent)
{
LogEventPropertyValue item;
if (logEvent.Properties.TryGetValue("SourceContext", out item))
{
yield return item.ToString()
.Replace("\"", "");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment