Last active
August 29, 2015 13:59
-
-
Save SimonCropp/10934590 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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