public void Setup() { _fakeRestClient = new Mock<IRestClient>(); _fakeRestClient .Setup(r => r.Put<ExceptionResponse>(It.IsAny<string>(), It.IsAny<ExceptionReport>())) .Callback<string, object>((target, report) => _submittedReport = (ExceptionReport)report); _client = new ExceptronClient(new ExceptronConfiguration { ApiKey = ApiKey }, appVersion) { RestClient = _fakeRestClient.Object }; }
protected override void Write(LogEventInfo logEvent) { if (logEvent == null || logEvent.Exception == null) { return; } InternalLogger.Debug("Sending Exception to api.exceptron.com. Process Name: {0}", Process.GetCurrentProcess().ProcessName); try { var exceptionData = new ExceptionData { Exception = logEvent.Exception, Component = logEvent.LoggerName, Message = logEvent.FormattedMessage, }; if (UserId != null) { exceptionData.UserId = UserId.Render(logEvent); } if (logEvent.Level <= LogLevel.Info) { exceptionData.Severity = ExceptionSeverity.None; } else if (logEvent.Level <= LogLevel.Warn) { exceptionData.Severity = ExceptionSeverity.Warning; } else if (logEvent.Level <= LogLevel.Error) { exceptionData.Severity = ExceptionSeverity.Error; } else if (logEvent.Level <= LogLevel.Fatal) { exceptionData.Severity = ExceptionSeverity.Fatal; } ExceptronClient.SubmitException(exceptionData); } catch (Exception e) { InternalLogger.Warn("Unable to report exception. {0}", e); throw; } }
protected override void Write(LogEventInfo logEvent) { if (logEvent == null || logEvent.Exception == null || logEvent.Exception.ExceptronShouldIgnore()) { return; } try { var exceptionData = new ExceptionData { Exception = logEvent.Exception, Component = logEvent.LoggerName, Message = logEvent.FormattedMessage, }; if (UserId != null) { exceptionData.UserId = UserId.Render(logEvent); } if (logEvent.Level <= LogLevel.Info) { exceptionData.Severity = ExceptionSeverity.None; } else if (logEvent.Level <= LogLevel.Warn) { exceptionData.Severity = ExceptionSeverity.Warning; } else if (logEvent.Level <= LogLevel.Error) { exceptionData.Severity = ExceptionSeverity.Error; } else if (logEvent.Level <= LogLevel.Fatal) { exceptionData.Severity = ExceptionSeverity.Fatal; } ExceptronClient.SubmitException(exceptionData); } catch (Exception e) { InternalLogger.Warn("Unable to report exception. {0}", e); } }
public void Setup() { _fakeRestClient = new Mock<IRestClient>(); _client = new ExceptronClient(new ExceptronConfiguration { ApiKey = ApiKey }, appVersion) { RestClient = _fakeRestClient.Object }; }