public async Task Invoke(HttpContext context, ITmsLogger tmsLogger) { _tmsLogger = tmsLogger; //TODO : Exact logging params have to be decided. _tmsLogger.LogInfo("Request started at " + context.Request.Path); await _next(context); _tmsLogger.LogInfo(context.Request.Path + "Request completed"); }
public async Task Invoke(HttpContext context, ITmsLogger tmsLogger) { try { _tmsLogger = tmsLogger; await _next(context); } catch (Exception ex) { var infoToLog = new LogDetails() { Message = ex.Message, Product = "TMS", Location = context.Request.Path, Hostname = Environment.MachineName, User = Environment.UserName, Exception = ex }; _tmsLogger.LogError(infoToLog); PathString originalPath = context.Request.Path; context.Request.Path = "/Home/Error"; context.Response.Clear(); var exceptionHandlerFeature = new ExceptionHandlerFeature() { Error = ex, Path = originalPath.Value, }; context.Features.Set <IExceptionHandlerFeature>(exceptionHandlerFeature); context.Features.Set <IExceptionHandlerPathFeature>(exceptionHandlerFeature); context.Response.StatusCode = 500; await _options.ExceptionHandler(context); return; } }
public CachedTrainingService(ITrainingService trainingService, ITmsCache cache, ITmsLogger logger) { _trainingService = trainingService; _cache = cache; _logger = logger; }