/// <summary> /// Create a logger /// </summary> /// <returns>A logger</returns> protected Logger CreateLogger() { this.LoggedExceptionList = new List <string>(); this.LoggingEnabledSetting = LoggingConfig.GetLoggingEnabledSetting(); // Setup the exception listener AppDomain currentDomain = AppDomain.CurrentDomain; if (LoggingConfig.GetFirstChanceHandler()) { currentDomain.FirstChanceException += this.FirstChanceHandler; } if (this.LoggingEnabledSetting != LoggingEnabled.NO) { return(LoggingConfig.GetLogger( StringProcessor.SafeFormatter( "{0} - {1}", this.GetFullyQualifiedTestClassName(), DateTime.UtcNow.ToString("yyyy-MM-dd-hh-mm-ss-ffff", CultureInfo.InvariantCulture)))); } else { return(new ConsoleLogger()); } }
public void GetLoggerDefault() { Config.AddTestSettingValues("Log", LoggingEnabled.YES.ToString(), "MagenicMaqs", true); Config.AddTestSettingValues("LogType", "Default", "MagenicMaqs", true); LoggingConfig.GetLogger(StringProcessor.SafeFormatter( "{0} - {1}", "Test", DateTime.UtcNow.ToString("yyyy-MM-dd-hh-mm-ss-ffff", CultureInfo.InvariantCulture))); }
public void GetFileLogger() { Config.AddTestSettingValues("LogLevel", MessageType.VERBOSE.ToString(), "MagenicMaqs", true); Config.AddTestSettingValues("Log", LoggingEnabled.YES.ToString(), "MagenicMaqs", true); Config.AddTestSettingValues("LogType", "TXT", "MagenicMaqs", true); var logger = LoggingConfig.GetLogger(StringProcessor.SafeFormatter( "{0} - {1}", "Test", DateTime.UtcNow.ToString("yyyy-MM-dd-hh-mm-ss-ffff", CultureInfo.InvariantCulture))); Assert.AreEqual(typeof(FileLogger), logger.GetType()); }
public void GetHTMLLogger() { string[] loggerType = { "HTML", "HTM" }; Config.AddTestSettingValues("LogLevel", MessageType.VERBOSE.ToString(), "MagenicMaqs", true); Config.AddTestSettingValues("Log", LoggingEnabled.YES.ToString(), "MagenicMaqs", true); for (int i = 0; i < loggerType.Length; i++) { Config.AddTestSettingValues("LogType", loggerType[i], "MagenicMaqs", true); var logger = LoggingConfig.GetLogger(StringProcessor.SafeFormatter( "{0} - {1}", "Test", DateTime.UtcNow.ToString("yyyy-MM-dd-hh-mm-ss-ffff", CultureInfo.InvariantCulture))); Assert.AreEqual(typeof(HtmlFileLogger), logger.GetType()); } }
public void GetConsoleLogger() { LoggingEnabled[] loggingEnableds = (LoggingEnabled[])Enum.GetValues(typeof(LoggingEnabled)); Config.AddTestSettingValues("LogType", "CONSOLE", "MagenicMaqs", true); for (int i = 0; i < loggingEnableds.Length; i++) { if (loggingEnableds[i] != LoggingEnabled.ONFAIL) { Config.AddTestSettingValues("Log", loggingEnableds[i].ToString(), "MagenicMaqs", true); var logger = LoggingConfig.GetLogger(StringProcessor.SafeFormatter( "{0} - {1}", "Test", DateTime.UtcNow.ToString("yyyy-MM-dd-hh-mm-ss-ffff", CultureInfo.InvariantCulture))); Assert.AreEqual(typeof(ConsoleLogger), logger.GetType()); } } }