static ISessionLogger CreateLogger(ConesoleConfiguration config, ISessionLogger baseLogger) { var loggers = new List<ISessionLogger> { baseLogger }; if (config.XmlConsole) { loggers.Add(new XmlSessionLogger(new XmlTextWriter(Console.Out){ Formatting = Formatting.Indented })); } else if(config.TeamCityOutput) loggers.Add(new TeamCityLogger(Console.Out)); else { var settings = new ConsoleLoggerSettings { Verbosity = config.Verbosity, SuccessColor = config.IsDryRun ? ConsoleColor.DarkGreen : ConsoleColor.Green, Multicore = config.Multicore, ShowTimings = config.ShowTimings, }; loggers.Add(new ConsoleSessionLogger(settings)); } if (config.XmlOutput.IsSomething) { loggers.Add(CreateXmlLogger(config.XmlOutput.Value)); } return loggers.Count == 1 ? loggers[0] : new MulticastSessionLogger(loggers); }
public ConsoleSessionLogger(ConsoleLoggerSettings settings) { this.settings = settings; switch(settings.Verbosity) { case LoggerVerbosity.Default: writer = new ConsoleLoggerWriter(); break; case LoggerVerbosity.Labels: writer = new LabledConsoleLoggerWriter(settings.Multicore ? new LabledConsoleLoggerContext() : settings.Context); break; case LoggerVerbosity.TestNames: writer = new TestNameConsoleLoggerWriter(); break; } writer.InfoColor = Console.ForegroundColor; writer.SuccessColor = settings.SuccessColor; }
private static IConsoleResultWriter CreateBaseWriter(ConsoleLoggerSettings settings) { ConsoleLoggerWriter writer = null; switch(settings.Verbosity) { case LoggerVerbosity.Default: writer = new ConsoleLoggerWriter(); break; case LoggerVerbosity.Labels: writer = new LabledConsoleLoggerWriter(new LabledConsoleLoggerContext(), settings.ShowTimings); break; case LoggerVerbosity.TestNames: writer = new TestNameConsoleLoggerWriter(); break; } writer.InfoColor = Console.ForegroundColor; writer.SuccessColor = settings.SuccessColor; return settings.Multicore ? MultiCoreConsoleResultWriter.For(writer) : writer; }
public ConsoleSessionLogger(ConsoleLoggerSettings settings) { this.settings = settings; this.writer = CreateBaseWriter(settings); this.suiteLogger = new ConsoleSuiteLogger(this.writer); }