/// <summary>
        /// <see cref="IModule.Configure"/>
        /// </summary>
        /// <param name="container"></param>
        public void Configure(IComponentRegistry container)
        {
            switch (_mode)
            {
            case LoggingMode.Console:
                LoggingStack.UseConsoleLog();
                break;

            case LoggingMode.Config:
                LoggingStack.UseConfig();
                break;

            case LoggingMode.File:
                LoggingStack.ConfigureFromFile(_fileName);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            var builder = new ContainerBuilder();

            // register log provider
            builder.RegisterInstance(LoggingStack.GetLogProvider()).As <ILogProvider, INamedProvider <ILog> >();
            builder.Register(c => c.Resolve <INamedProvider <ILog> >().Get("Default"));
            builder.Update(container);
        }
Ejemplo n.º 2
0
        public void Test_DailyLog()
        {
            Assert.IsFalse(Directory.Exists(TestPath));

            LoggingStack.UseDailyLog(TestLog);
            LoggingStack.GetLog().Error(new Exception(), "Some exception");

            Assert.IsTrue(File.Exists(TestLog), "Log should be created");
        }
Ejemplo n.º 3
0
        public void Test_RollingLog()
        {
            Assert.IsFalse(File.Exists(TestLog), "File should not exist before test");

            LoggingStack.UseRollingLog(TestLog, 10.Mb(), 10);
            LoggingStack.GetLog().Error(new Exception(), "Test");

            Assert.IsTrue(File.Exists(TestLog), "Log should be created");
        }
Ejemplo n.º 4
0
        public void Dispose()
        {
            LoggingStack.Reset();
            if (Directory.Exists(TestPath))
            {
                Directory.Delete(TestPath, true);
            }

            Console.SetOut(_out);
        }
Ejemplo n.º 5
0
 public void Test_ConsoleLog()
 {
     using (var writer = new StringWriter())
     {
         Console.SetOut(writer);
         LoggingStack.UseConsoleLog();
         LoggingStack.GetLog().Error(new Exception(), "Some exception");
         Enforce.That(writer.ToString(), StringIs.NotEmpty);
     }
 }
 public void TearDown()
 {
     LoggingStack.Reset();
 }