示例#1
0
        public static void EnsurePreConditions(AuthLogOptions 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);
            }
        }
示例#2
0
 public AuthLogMiddleWare(RequestDelegate next, IOptions <AuthLogOptions> options, ILoggerFactory loggerFactory)
 {
     this._next    = next;
     this._options = options.Value;
     _logger       = loggerFactory.CreateLogger <AuthLogMiddleWare>();
 }
示例#3
0
        public static IApplicationBuilder UseAuthLog(this IApplicationBuilder builder, AuthLogOptions options)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            return(builder.UseMiddleware <AuthLogMiddleWare>(Options.Create(options)));
        }