Ejemplo n.º 1
0
        public static void EnsurePreConditions(MVCLogOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (string.IsNullOrWhiteSpace(options.LogPath))
            {
                throw new ArgumentException("系统日志文件存储路径未配置", nameof(options.LogPath));
            }

            if (string.IsNullOrWhiteSpace(options.PathFormat))
            {
                throw new ArgumentException("系统日志文件名称未配置", nameof(options.PathFormat));
            }

            if (!Directory.Exists(options.LogPath))
            {
                Directory.CreateDirectory(options.LogPath);
            }
        }
Ejemplo n.º 2
0
        public static IApplicationBuilder UseAuthLog(this IApplicationBuilder builder, MVCLogOptions options)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(builder.UseMiddleware <MVCLogMiddleWare>(Options.Create(options)));
        }
Ejemplo n.º 3
0
 public MVCLogMiddleWare(RequestDelegate next, IOptions <MVCLogOptions> options, ILoggerFactory loggerFactory)
 {
     _next    = next;
     _options = options.Value;
     _logger  = loggerFactory.CreateLogger <MVCLogMiddleWare>();
 }