public static IApplicationBuilder UsePerformanceLog(this IApplicationBuilder app, Action <ILogOptions> action)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }
            var options = new LogOptions();

            action.Invoke(options);

            return(app.UseMiddleware <LogMiddleware>(options));
        }
示例#2
0
 //Explicit Dependencies Principle
 public LogMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, LogOptions options)
 {
     _next    = next;
     _logger  = loggerFactory.CreateLogger("performance");
     _options = options;
 }
        public static IApplicationBuilder UsePerformanceLog(this IApplicationBuilder app, LogOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(app.UseMiddleware <LogMiddleware>(options));
        }