static void InitBody() { if (options == null) { options = new Options("", "Log"); } LogDefaultOptions.AddDefaultOptions(options); LogLevel.SetLevel(LogLevel.Always, options[LogDefaultOptions.AlwaysOption]); LogLevel.SetLevel(LogLevel.Fatal, options[LogDefaultOptions.FatalOption]); LogLevel.SetLevel(LogLevel.Error, options[LogDefaultOptions.ErrorOption]); LogLevel.SetLevel(LogLevel.Warning, options[LogDefaultOptions.WarningOption]); LogLevel.SetLevel(LogLevel.Info, options[LogDefaultOptions.InfoOption]); LogLevel.SetLevel(LogLevel.Event, options[LogDefaultOptions.EventOption]); LogLevel.SetLevel(LogLevel.Debug, options[LogDefaultOptions.DebugOption]); LogLevel.SetLevel(LogLevel.All, options[LogDefaultOptions.AllOption]); LogLevel.SetDefault(options["LogLevel"]); if (collector != null) { collector.ShutDown(); } collector = new LogCollector(new ConcurrentQueued <LogItem>(new PoolThreadStarter()), new LogWriterFactory(options).GetWriter()); if (container == null) { container = new LoggerContainer(category => new CheckingLogger(category, collector.Send, LogLevel.Default)); } else { container.SetSender(collector.Send); } container.DefaultCategory = options.Get("LogDefaultCategory", "Default"); init = true; }
public void ShutDownTest() { LogItem message = new LogItem(category, level, msg, ids, GetException()); var qThread = new Mock<IQueued<LogItem>>(MockBehavior.Strict); var writer = new Mock<ILogWriter>(MockBehavior.Strict); qThread .Setup(s => s.Terminate()); writer .Setup(s => s.GetTimeout()) .Returns(timeout); qThread .Setup(s => s.SetTimeout(It.IsAny<int>())); LogCollector target = new LogCollector(qThread.Object, writer.Object); target.ShutDown(); qThread .Verify(s => s.Terminate(), Times.Once()); }