async Task <IReadOnlyList <Training> > ICachedTrainingService.ListTrainings() { _logger.LogInfo("ListTrainings Start "); var cache_key = ListTrainings_CacheKey; var trainings = await _cache.GetAsync <IReadOnlyList <Training> >(cache_key); if (trainings == null) { trainings = await _trainingService.ListTrainings(); await _cache.SetAsync(cache_key, trainings); } _logger.LogInfo("ListTrainings End "); _logger.LogError("ListTrainings : Testing error logging."); //TODO: cleanup return(trainings); }
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; } }