예제 #1
0
        /// <summary>
        ///     Introduces a step that logs all gets and sets of the mocked indexer to a log context, where
        ///     the log context is provided by an <see cref="ILogContextProvider" />.
        /// </summary>
        /// <typeparam name="TKey">The type of the indexer key.</typeparam>
        /// <typeparam name="TValue">The type of the indexer value.</typeparam>
        /// <param name="caller">The mock or step to which this 'log' step is added.</param>
        /// <param name="logContextProvider">An instance from which we can get an <see cref="ILogContext" /> to use.</param>
        /// <returns>An <see cref="ICanHaveNextIndexerStep{TKey, TValue}" /> that can be used to add further steps.</returns>
        public static ICanHaveNextIndexerStep <TKey, TValue> Log <TKey, TValue>(
            this ICanHaveNextIndexerStep <TKey, TValue> caller,
            ILogContextProvider logContextProvider)
        {
            if (logContextProvider == null)
            {
                throw new ArgumentNullException(nameof(logContextProvider));
            }

            return(caller.SetNextStep(new LogIndexerStep <TKey, TValue>(logContextProvider.LogContext)));
        }
예제 #2
0
        /// <summary>
        ///     Introduces a step that logs all adds and removes of event handlers to the mocked event to a log context, where
        ///     the log context is provided by an <see cref="ILogContextProvider" />.
        /// </summary>
        /// <typeparam name="THandler">The event handler type for the event.</typeparam>
        /// <param name="caller">The mock or step to which this 'log' step is added.</param>
        /// <param name="logContextProvider">An instance from which we can get an <see cref="ILogContext" /> to use.</param>
        /// <returns>An <see cref="ICanHaveNextEventStep{THandler}" /> that can be used to add further steps.</returns>
        public static ICanHaveNextEventStep <THandler> Log <THandler>(
            this ICanHaveNextEventStep <THandler> caller,
            ILogContextProvider logContextProvider) where THandler : Delegate
        {
            if (logContextProvider == null)
            {
                throw new ArgumentNullException(nameof(logContextProvider));
            }

            return(caller.SetNextStep(new LogEventStep <THandler>(logContextProvider.LogContext)));
        }
예제 #3
0
        /// <summary>
        ///     Introduces a step that logs all calls to the mocked method to a log context, where
        ///     the log context is provided by an <see cref="ILogContextProvider" />.
        /// </summary>
        /// <typeparam name="TParam">The method parameter type.</typeparam>
        /// <typeparam name="TResult">The method return type.</typeparam>
        /// <param name="caller">The mock or step to which this 'log' step is added.</param>
        /// <param name="logContextProvider">An instance from which we can get an <see cref="ILogContext" /> to use.</param>
        /// <returns>An <see cref="ICanHaveNextMethodStep{TParam, TResult}" /> that can be used to add further steps.</returns>
        public static ICanHaveNextMethodStep <TParam, TResult> Log <TParam, TResult>(
            this ICanHaveNextMethodStep <TParam, TResult> caller,
            ILogContextProvider logContextProvider)
        {
            if (logContextProvider == null)
            {
                throw new ArgumentNullException(nameof(logContextProvider));
            }

            return(caller.SetNextStep(new LogMethodStep <TParam, TResult>(logContextProvider.LogContext)));
        }
 public LogAddRepository(ILogContextProvider contextProvider)
 {
     _contextProvider = contextProvider;
 }
예제 #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ILogContextProvider logContextProvider)
        {
            loggerFactory.AddLogstashLogger(Configuration.GetSection("Logger"), logContextProvider: logContextProvider);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseRequestLogging();
            app.UseHttpsRedirection();
            app.UseAuthentication();

            app.UseMvc();
        }
예제 #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ILogContextProvider logContextProvider)
        {
            loggerFactory.AddLogstashLogger(Configuration.GetSection("Logger"), logContextProvider: logContextProvider);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler();
                //app.UseHsts();
            }

            app.UseRequestLogging();
            app.UseAuthentication();

            app.UseMvc();

            //app.Run(async (context) =>
            //{
            //   // await context.Response.WriteAsync("Hello World!");
            //});
        }
예제 #7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ILogContextProvider logContextProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            app.UseRequestLogging();
            app.UseHttpsRedirection();

            app.UseMvc();
        }