コード例 #1
0
        private static void ConfigureLog4Net(ContainerBuilder containerBuilder)
        {
            XmlConfigurator.Configure();
            var logManager = new LogManagerAdapter();

            containerBuilder.RegisterInstance(logManager).As <ILogManager>();
        }
コード例 #2
0
        private void ConfigureLog4net(IKernel container)
        {
            XmlConfigurator.Configure();
            var logManager = new LogManagerAdapter();

            container.Bind <ILogManager>().ToConstant(logManager);
        }
コード例 #3
0
        public void IsErrorEnabled_CreateAdapterWhereErrorIsEnabled_ReturnsTrue()
        {
            GetMemoryAppender("${message}", LogLevel.Error);
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            Assert.IsTrue(logger.IsErrorEnabled);
        }
コード例 #4
0
        public void IsWarnEnabled_CreateAdapterWhereWarnIsNotEnabled_ReturnsFalse()
        {
            GetMemoryAppender("${message}", LogLevel.Fatal);
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            Assert.IsFalse(logger.IsWarnEnabled);
        }
コード例 #5
0
        public void IsErrorEnabled_CreateAdapterWhereErrorIsNotEnabled_ReturnsFalse()
        {
            GetMemoryAppender("FATAL");
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            Assert.IsFalse(logger.IsErrorEnabled);
        }
コード例 #6
0
        public void GetLogger_SendInAnyType_ReturnsLogAdapterWithCorrectName()
        {
            var adapter = new LogManagerAdapter();

            var result = (LogAdapter)adapter.GetLogger(GetType());

            Assert.AreEqual(GetType().FullName, result.LoggerName);
        }
コード例 #7
0
        public void IsFatalEnabled_CreateAdapterWhereFatalIsEnabled_ReturnsTrue()
        {
            GetMemoryAppender("FATAL");
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            Assert.IsTrue(logger.IsFatalEnabled);
        }
コード例 #8
0
        public void GetLogger_SendInAnyType_ReturnsLogAdapter()
        {
            var adapter = new LogManagerAdapter();

            var result = adapter.GetLogger(GetType());

            Assert.IsInstanceOf <LogAdapter>(result);
        }
コード例 #9
0
        public void GetLogger_SendInAnyName_ReturnsLogAdapterWithCorrectName()
        {
            var adapter = new LogManagerAdapter();

            var result = (LogAdapter)adapter.GetLogger("Any name");

            Assert.AreEqual("Any name", result.LoggerName);
        }
コード例 #10
0
ファイル: Bindings.cs プロジェクト: Warshavski/Converter
        private void ConfigureLog4Net()
        {
            XmlConfigurator.Configure();

            var logManager = new LogManagerAdapter();

            Bind <ILogManager>().ToConstant(logManager);
        }
コード例 #11
0
        private void ConfigureLog4net(ContainerBuilder builder)
        {
            XmlConfigurator.Configure();

            var logManager = new LogManagerAdapter();

            builder.RegisterType <LogManagerAdapter>().As <ILogManager>().SingleInstance();
        }
コード例 #12
0
        public void IsDebugEnabled_CreateAdapterWhereDebugIsEnabled_ReturnsTrue()
        {
            GetMemoryAppender("DEBUG");
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            Assert.IsTrue(logger.IsDebugEnabled);
        }
コード例 #13
0
        private void ConfigureLog4net(IKernel container)
        {
            // we create a class because this is required to configure log4net.
            XmlConfigurator.Configure();
            var logManager = new LogManagerAdapter();

            container.Bind <ILogManager>().ToConstant(logManager);
        }
コード例 #14
0
        public void Debug_LogMessage_MessageWrittenToAdapter()
        {
            var memoryAppender        = GetMemoryAppender("${message}");
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            logger.Debug("Any message");

            Assert.AreEqual("Any message", memoryAppender.Logs[0]);
        }
コード例 #15
0
        public void Fatal_LogMessageToCurrentClassAdapter_MessageWrittenCurrentClassLogger()
        {
            var memoryAppender        = GetMemoryAppender("${logger}");
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            logger.Fatal("Any message");

            Assert.AreEqual(typeof(LogManagerAdapterTests).FullName, memoryAppender.Logs[0]);
        }
コード例 #16
0
        public void Debug_LogMessage_MessageLevelSetToDebug()
        {
            var memoryAppender        = GetMemoryAppender("${level}");
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            logger.Debug("Any message");

            Assert.AreEqual("Debug", memoryAppender.Logs[0]);
        }
コード例 #17
0
        public void Fatal_LogMessageWithException_ExceptionLogged()
        {
            var memoryAppender        = GetMemoryAppender("${exception}");
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            logger.Fatal("Any message", new Exception("Any exception message"));

            Assert.AreEqual("Any exception message", memoryAppender.Logs[0]);
        }
コード例 #18
0
        public void Debug_LogMessage_MessageLevelSetToDebug()
        {
            var memoryAppender        = GetMemoryAppender();
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            logger.Debug("Any message");

            Assert.AreEqual("DEBUG", memoryAppender.GetEvents()[0].Level.DisplayName);
        }
コード例 #19
0
        public void Debug_LogMessageWithException_ExceptionLogged()
        {
            var memoryAppender        = GetMemoryAppender();
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            logger.Debug("Any message", new Exception("Any exception message"));

            Assert.AreEqual("Any exception message", memoryAppender.GetEvents()[0].ExceptionObject.Message);
        }
コード例 #20
0
        public void Fatal_LogMessage_MessageWrittenToAdapter()
        {
            var memoryAppender        = GetMemoryAppender();
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            logger.Fatal("Any message");

            Assert.AreEqual("Any message", memoryAppender.GetEvents()[0].RenderedMessage);
        }
コード例 #21
0
        public void Debug_LogMessageToCurrentClassAdapter_MessageWrittenCurrentClassLogger()
        {
            var memoryAppender        = GetMemoryAppender();
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            logger.Debug("Any message");

            Assert.AreEqual(typeof(LogManagerAdapterTests).FullName, memoryAppender.GetEvents()[0].LoggerName);
        }
コード例 #22
0
        public void DebugFormat_LogMessageWithFormatProviderAndDateAndTellToFormatAsIso_DateFormatAfterIsoStandard()
        {
            var memoryAppender        = GetMemoryAppender();
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            var date = new DateTime(2000, 1, 1);

            logger.DebugFormat(CultureInfo.InvariantCulture, "{0:s}", date);

            Assert.AreEqual("2000-01-01T00:00:00", memoryAppender.GetEvents()[0].RenderedMessage);
        }
コード例 #23
0
        public void FatalFormat_LogMessageWithDateAndTellToFormatAsIso_DateFormatAfterIsoStandard()
        {
            var memoryAppender        = GetMemoryAppender("${message}");
            var log4netManagerAdapter = new LogManagerAdapter();
            var logger = log4netManagerAdapter.GetCurrentClassLogger();

            var date = new DateTime(2000, 1, 1);

            logger.FatalFormat("{0:s}", date);

            Assert.AreEqual("2000-01-01T00:00:00", memoryAppender.Logs[0]);
        }
コード例 #24
0
        private static void ConfigureLog4Net(IKernel container)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            XmlConfigurator.Configure();

            var logManager = new LogManagerAdapter();

            container.Bind <ILogManager>().ToConstant(logManager);
        }
コード例 #25
0
ファイル: Program.cs プロジェクト: Warshavski/Converter
        private static void ConfigureLogging(IApplicationController controller)
        {
            XmlConfigurator.Configure();

            var logManager = new LogManagerAdapter();

            controller.RegisterInstance <ILogManager>(logManager);

            //*** check for correct implementation
            // logs all unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                var log       = logManager.GetLog(typeof(Program));
                var exception = (Exception)e.ExceptionObject;
                log.Error(exception.ToString());
            };
        }
コード例 #26
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind <IUnitOfWork>().To <BodyBuildingContext>().InRequestScope();
            kernel.Bind <IMuscleRepository>().To <MuscleRepository>();
            kernel.Bind <IAddMuscleMaintenanceProcessor>().To <AddMuscleMaintenanceProcessor>();

            XmlConfigurator.Configure();
            var logManager = new LogManagerAdapter();

            kernel.Bind <ILogManager>().ToConstant(logManager);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MuscleEntityToMuscleAutoMapperTypeConfigurator());
            });

            //services.AddSingleton<IMapper>(sp => config.CreateMapper())
            kernel.Bind <IMapper>().ToMethod(c => config.CreateMapper()).InSingletonScope();
        }
コード例 #27
0
        private void ConfigureNLog()
        {
            var manager = new LogManagerAdapter();

            container.RegisterInstance <ILogManager>(manager);
        }
コード例 #28
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind<IUnitOfWork>().To<BodyBuildingContext>().InRequestScope();
            kernel.Bind<IMuscleRepository>().To<MuscleRepository>();
            kernel.Bind<IAddMuscleMaintenanceProcessor>().To<AddMuscleMaintenanceProcessor>();

            XmlConfigurator.Configure();
            var logManager = new LogManagerAdapter();
            kernel.Bind<ILogManager>().ToConstant(logManager);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MuscleEntityToMuscleAutoMapperTypeConfigurator());
            });
            //services.AddSingleton<IMapper>(sp => config.CreateMapper())
            kernel.Bind<IMapper>().ToMethod(c => config.CreateMapper()).InSingletonScope();
        }