Пример #1
0
        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");
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
 public CachedTrainingService(ITrainingService trainingService, ITmsCache cache, ITmsLogger logger)
 {
     _trainingService = trainingService;
     _cache           = cache;
     _logger          = logger;
 }