public void Log() { var mockContextLogger = new Mock <IContextExceptionLogger>(); var logger = new GoogleExceptionLogger(mockContextLogger.Object); logger.Log(_exception, _context); mockContextLogger.Verify(lb => lb.Log(_exception, It.IsAny <HttpContextWrapper>())); }
public void Log() { var mockAccessor = new Mock <IHttpContextAccessor>(); var mockContextLogger = new Mock <IContextExceptionLogger>(); var logger = new GoogleExceptionLogger(mockContextLogger.Object, mockAccessor.Object); logger.Log(_exception, new DefaultHttpContext()); mockContextLogger.Verify(lb => lb.Log(_exception, It.IsAny <HttpContextWrapper>())); }
public void ErrorLogging(Exception e) { string projectId = "jurgen-cloud-project"; string serviceName = "PFTCAssignment"; string version = "1"; var exceptionError = GoogleExceptionLogger.Create(projectId, serviceName, version); exceptionError.Log(e); }
//Error logging public void LogError(Exception message) { string projectId = "pfc-home"; string serviceName = "pfc-home-app"; string version = "4.0.0"; var exceptionLogger = GoogleExceptionLogger.Create(projectId, serviceName, version); exceptionLogger.Log(message); }
public void Log_NullContext() { var mockContextLogger = new Mock <IContextExceptionLogger>(); var logger = new GoogleExceptionLogger(mockContextLogger.Object); HttpContext.Current = null; logger.Log(_exception); mockContextLogger.Verify(lb => lb.Log(_exception, It.IsAny <HttpContextWrapper>())); }
public void Log_NoContext_NoAccessorContext() { var mockAccessor = new Mock <IHttpContextAccessor>(); mockAccessor.Setup(a => a.HttpContext).Returns <DefaultHttpContext>(null); var mockContextLogger = new Mock <IContextExceptionLogger>(); var logger = new GoogleExceptionLogger(mockContextLogger.Object, mockAccessor.Object); logger.Log(_exception); mockContextLogger.Verify(lb => lb.Log(_exception, It.IsAny <HttpContextWrapper>())); }
public void LogError(Exception e) { //for beta versions you have check a small checkbox called include pre-release string projectId = "programmingforthecloudbf"; //your project id string serviceName = "BFError"; //your application name (which you can invent) string version = "1"; //any version which you're working on at the moment (which you can invent) var exceptionLogger = GoogleExceptionLogger.Create(projectId, serviceName, version); exceptionLogger.Log(e); }
public async Task LogAsync() { var mockContextLogger = new Mock <IContextExceptionLogger>(); var logger = new GoogleExceptionLogger(mockContextLogger.Object); mockContextLogger.Setup(lb => lb.LogAsync( It.IsAny <Exception>(), It.IsAny <IContextWrapper>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(true)); await logger.LogAsync(_exception, _context); mockContextLogger.Verify(lb => lb.LogAsync(_exception, It.IsAny <HttpContextWrapper>(), It.IsAny <CancellationToken>())); }
public async Task LogAsync() { var mockAccessor = new Mock <IHttpContextAccessor>(); var mockContextLogger = new Mock <IContextExceptionLogger>(); mockContextLogger.Setup(lb => lb.LogAsync( It.IsAny <Exception>(), It.IsAny <IContextWrapper>(), It.IsAny <CancellationToken>())) .Returns(Task.CompletedTask); var logger = new GoogleExceptionLogger(mockContextLogger.Object, mockAccessor.Object); await logger.LogAsync(_exception, new DefaultHttpContext()); mockContextLogger.Verify(lb => lb.LogAsync(_exception, It.IsAny <HttpContextWrapper>(), It.IsAny <CancellationToken>())); }
public string ThrowCatchWithGoogleLogger(string id) { var exceptionLogger = GoogleExceptionLogger.Create(TestEnvironment.GetTestProjectId(), EntryData.Service, EntryData.Version); var message = EntryData.GetMessage(nameof(ThrowCatchWithGoogleLogger), id); try { throw new Exception(message); } catch (Exception e) { exceptionLogger.Log(e); } return(message); }
public string ThrowCatchWithGoogleLogger(string id) { var exceptionLogger = GoogleExceptionLogger.Create(ProjectId, Service, Version); var message = GetMessage(nameof(ThrowCatchWithGoogleLogger), id); try { throw new Exception(message); } catch (Exception e) { exceptionLogger.Log(e); } return(message); }
// End sample public void ReadFile() { // Sample: LogExceptionsMVC string projectId = "[Google Cloud Platform project ID]"; string serviceName = "[Name of service]"; string version = "[Version of service]"; var exceptionLogger = GoogleExceptionLogger.Create(projectId, serviceName, version); try { string scores = File.ReadAllText(@"C:\Scores.txt"); Console.WriteLine(scores); } catch (IOException e) { exceptionLogger.Log(e); } // End sample }
public ErrorReportingController() { _exceptionLogger = GoogleExceptionLogger.Create(ProjectId, Service, Version); }
public static void ReportError(Exception ex) { var myLogger = GoogleExceptionLogger.Create("programming-for-the-cloud", "pftcLog", "1"); myLogger.Log(ex); }