void ColorTest() { Log.AddDebugLogger(); Log.SetDomain("/COLORS", Scope.Method); Log.Info("Hello ALox, this debug logging"); Log.Verbose("Some verbose log output"); Log.Warning("A warning"); Log.Error("An error"); Log.Info("Playing with colors. Depending on the test environment, the colors might " + "be visible or not"); Log.Info("In the memory logger, all color/style codes have to disappear (by default)"); Log.Verbose("A verbose message"); Log.Info("An info message"); Log.Warning("A warning message"); Log.Error("An error message"); Log.Info("FG Colors: " + ">>>" + ESC.RED + "RED" + ESC.FG_RESET + "<<<" + ">>>" + ESC.GREEN + "GREEN" + ESC.FG_RESET + "<<<" + ">>>" + ESC.BLUE + "BLUE" + ESC.FG_RESET + "<<<" + ">>>" + ESC.CYAN + "CYAN" + ESC.FG_RESET + "<<<" + ">>>" + ESC.MAGENTA + "MAGENTA" + ESC.FG_RESET + "<<<" + ">>>" + ESC.YELLOW + "YELLOW" + ESC.FG_RESET + "<<<" + ">>>" + ESC.GRAY + "GRAY" + ESC.FG_RESET + "<<<" + ">>>" + ESC.WHITE + "WHITE" + ESC.FG_RESET + "<<<" + ">>>" + ESC.BLACK + "BLACK" + ESC.FG_RESET + "<<<" ); Log.Info("BG Colors: " + ">>>" + ESC.BG_RED + "RED" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_GREEN + "GREEN" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_BLUE + "BLUE" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_CYAN + "CYAN" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_MAGENTA + "MAGENTA" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_YELLOW + "YELLOW" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_GRAY + "GRAY" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_WHITE + "WHITE" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_BLACK + "BLACK" + ESC.BG_RESET + "<<<" ); Log.Info("FG/BG same: " + ">>>" + ESC.RED + ESC.BG_RED + "RED" + ESC.RESET + "<<<" + ">>>" + ESC.GREEN + ESC.BG_GREEN + "GREEN" + ESC.RESET + "<<<" + ">>>" + ESC.BLUE + ESC.BG_BLUE + "BLUE" + ESC.RESET + "<<<" + ">>>" + ESC.CYAN + ESC.BG_CYAN + "CYAN" + ESC.RESET + "<<<" + ">>>" + ESC.MAGENTA + ESC.BG_MAGENTA + "MAGENTA" + ESC.RESET + "<<<" + ">>>" + ESC.YELLOW + ESC.BG_YELLOW + "YELLOW" + ESC.RESET + "<<<" + ">>>" + ESC.GRAY + ESC.BG_GRAY + "GRAY" + ESC.RESET + "<<<" + ">>>" + ESC.WHITE + ESC.BG_WHITE + "WHITE" + ESC.RESET + "<<<" + ">>>" + ESC.BLACK + ESC.BG_BLACK + "BLACK" + ESC.RESET + "<<<" ); #if ALOX_DBG_LOG AnsiConsoleLogger acl = (AnsiConsoleLogger)Log.GetLogger("ANSI_CONSOLE"); ColorConsoleLogger ccl = (ColorConsoleLogger)Log.GetLogger("COLORCONSOLE"); if (acl != null) { acl.IsBackgroundLight = !acl.IsBackgroundLight; } if (ccl != null) { ccl.IsBackgroundLight = !ccl.IsBackgroundLight; } #endif Log.Info("Same rev.: " + ">>>" + ESC.RED + ESC.BG_RED + "RED" + ESC.RESET + "<<<" + ">>>" + ESC.GREEN + ESC.BG_GREEN + "GREEN" + ESC.RESET + "<<<" + ">>>" + ESC.BLUE + ESC.BG_BLUE + "BLUE" + ESC.RESET + "<<<" + ">>>" + ESC.CYAN + ESC.BG_CYAN + "CYAN" + ESC.RESET + "<<<" + ">>>" + ESC.MAGENTA + ESC.BG_MAGENTA + "MAGENTA" + ESC.RESET + "<<<" + ">>>" + ESC.YELLOW + ESC.BG_YELLOW + "YELLOW" + ESC.RESET + "<<<" + ">>>" + ESC.GRAY + ESC.BG_GRAY + "GRAY" + ESC.RESET + "<<<" + ">>>" + ESC.WHITE + ESC.BG_WHITE + "WHITE" + ESC.RESET + "<<<" + ">>>" + ESC.BLACK + ESC.BG_BLACK + "BLACK" + ESC.RESET + "<<<" ); #if ALOX_DBG_LOG if (acl != null) { acl.IsBackgroundLight = !acl.IsBackgroundLight; } if (ccl != null) { ccl.IsBackgroundLight = !ccl.IsBackgroundLight; } #endif Log.Info("Reset FG/BG: " + ESC.BG_RED + "BG RED" + ESC.GREEN + "FG REEN" + ESC.FG_RESET + "FG Reset" + ESC.BG_RESET + "BG Reset" ); Log.Info("Reset FG/BG: " + ESC.BG_RED + "BG RED" + ESC.GREEN + "FG REEN" + ESC.BG_RESET + "BG Reset" + ESC.FG_RESET + "FG Reset" ); Log.Info("Reset FG/BG: " + ESC.BG_RED + "BG RED" + ESC.GREEN + "FG REEN" + ESC.RESET + "All Reset" ); Log.Info("Styles: " + ">>>" + ESC.BOLD + "Bold" + ESC.STYLE_RESET + "<<<" + ">>>" + ESC.ITALICS + "Italics" + ESC.STYLE_RESET + "<<<" + ">>>" + ESC.BOLD + ">>>" + ESC.ITALICS + "Bold/Italics" + ESC.STYLE_RESET + "<<<" ); Log.Info("Reset Style/FG/BG: " + ESC.BOLD + "Bold" + ESC.BG_RED + "BG RED" + ESC.GREEN + "FG REEN" + ESC.BG_RESET + "BG Reset" + ESC.FG_RESET + "FG Reset" + ESC.STYLE_RESET + "Style Reset" ); Log.Info("Reset Style/FG/BG: " + ESC.BOLD + "Bold" + ESC.BG_RED + "BG RED" + ESC.GREEN + "FG REEN" + ESC.RESET + "Reset All" ); Log.Info("Reset Style/FG/BG: " + ESC.BOLD + "Bold" + ESC.BG_RED + "BG RED" + ESC.GREEN + "FG REEN" + ESC.STYLE_RESET + "Style Reset" + ESC.BG_RESET + "BG Reset" + ESC.FG_RESET + "FG Reset" + " +< This does not work on ANSI terminals: Styl reset, resets ALL here" ); Log.Info("An URL: " + ESC.URL_START + "www.darwin.heaven" + ESC.URL_END + ", your resource for happyness!" ); }
public void Log_ColorsAndStyles() { UT_INIT(); Log.AddDebugLogger(); Log.SetDomain("COLORS", Scope.Method); #if ALOX_DBG_LOG MemoryLogger ml = new MemoryLogger(); Log.SetVerbosity(ml, Verbosity.Verbose, "/"); #endif Log.SetVerbosity(Log.DebugLogger, Verbosity.Verbose, "/"); Log.Info("Playing with colors. Depending on the test environment, the colors might " + "be visible or not"); Log.Info("In the memory logger, all color/style codes have to disappear (by default)"); Log.Verbose("A verbose message"); Log.Info("An info message"); Log.Warning("A warning message"); Log.Error("An error message"); #if ALOX_DBG_LOG int mlPos = ml.MemoryLog.IndexOf("/COLORS"); UT_TRUE(mlPos > 0); mlPos += 8; #endif Log.Info("FG Colors: " + ">>>" + ESC.RED + "RED" + ESC.FG_RESET + "<<<" + ">>>" + ESC.GREEN + "GREEN" + ESC.FG_RESET + "<<<" + ">>>" + ESC.BLUE + "BLUE" + ESC.FG_RESET + "<<<" + ">>>" + ESC.CYAN + "CYAN" + ESC.FG_RESET + "<<<" + ">>>" + ESC.MAGENTA + "MAGENTA" + ESC.FG_RESET + "<<<" + ">>>" + ESC.YELLOW + "YELLOW" + ESC.FG_RESET + "<<<" + ">>>" + ESC.GRAY + "GRAY" + ESC.FG_RESET + "<<<" + ">>>" + ESC.WHITE + "WHITE" + ESC.FG_RESET + "<<<" + ">>>" + ESC.BLACK + "BLACK" + ESC.FG_RESET + "<<<" ); #if ALOX_DBG_LOG UT_TRUE(ml.MemoryLog.IndexOf("\x1B") < 0); ml.MemoryLog.Clear(); #endif Log.Info("BG Colors: " + ">>>" + ESC.BG_RED + "RED" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_GREEN + "GREEN" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_BLUE + "BLUE" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_CYAN + "CYAN" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_MAGENTA + "MAGENTA" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_YELLOW + "YELLOW" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_GRAY + "GRAY" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_WHITE + "WHITE" + ESC.BG_RESET + "<<<" + ">>>" + ESC.BG_BLACK + "BLACK" + ESC.BG_RESET + "<<<" ); #if ALOX_DBG_LOG UT_TRUE(ml.MemoryLog.IndexOf("\x1B") < 0); ml.MemoryLog.Clear(); #endif Log.Info("FG/BG same: " + ">>>" + ESC.RED + ESC.BG_RED + "RED" + ESC.RESET + "<<<" + ">>>" + ESC.GREEN + ESC.BG_GREEN + "GREEN" + ESC.RESET + "<<<" + ">>>" + ESC.BLUE + ESC.BG_BLUE + "BLUE" + ESC.RESET + "<<<" + ">>>" + ESC.CYAN + ESC.BG_CYAN + "CYAN" + ESC.RESET + "<<<" + ">>>" + ESC.MAGENTA + ESC.BG_MAGENTA + "MAGENTA" + ESC.RESET + "<<<" + ">>>" + ESC.YELLOW + ESC.BG_YELLOW + "YELLOW" + ESC.RESET + "<<<" + ">>>" + ESC.GRAY + ESC.BG_GRAY + "GRAY" + ESC.RESET + "<<<" + ">>>" + ESC.WHITE + ESC.BG_WHITE + "WHITE" + ESC.RESET + "<<<" + ">>>" + ESC.BLACK + ESC.BG_BLACK + "BLACK" + ESC.RESET + "<<<" ); #if ALOX_DBG_LOG AnsiConsoleLogger acl = (AnsiConsoleLogger)Log.GetLogger("ANSI_CONSOLE"); ColorConsoleLogger ccl = (ColorConsoleLogger)Log.GetLogger("COLORCONSOLE"); if (acl != null) { acl.IsBackgroundLight = !acl.IsBackgroundLight; } if (ccl != null) { ccl.IsBackgroundLight = !ccl.IsBackgroundLight; } #endif Log.Info("Same rev.: " + ">>>" + ESC.RED + ESC.BG_RED + "RED" + ESC.RESET + "<<<" + ">>>" + ESC.GREEN + ESC.BG_GREEN + "GREEN" + ESC.RESET + "<<<" + ">>>" + ESC.BLUE + ESC.BG_BLUE + "BLUE" + ESC.RESET + "<<<" + ">>>" + ESC.CYAN + ESC.BG_CYAN + "CYAN" + ESC.RESET + "<<<" + ">>>" + ESC.MAGENTA + ESC.BG_MAGENTA + "MAGENTA" + ESC.RESET + "<<<" + ">>>" + ESC.YELLOW + ESC.BG_YELLOW + "YELLOW" + ESC.RESET + "<<<" + ">>>" + ESC.GRAY + ESC.BG_GRAY + "GRAY" + ESC.RESET + "<<<" + ">>>" + ESC.WHITE + ESC.BG_WHITE + "WHITE" + ESC.RESET + "<<<" + ">>>" + ESC.BLACK + ESC.BG_BLACK + "BLACK" + ESC.RESET + "<<<" ); #if ALOX_DBG_LOG if (acl != null) { acl.IsBackgroundLight = !acl.IsBackgroundLight; } if (ccl != null) { ccl.IsBackgroundLight = !ccl.IsBackgroundLight; } #endif #if ALOX_DBG_LOG Log.Verbose(ml.MemoryLog.ToString(mlPos)); UT_TRUE(ml.MemoryLog.IndexOf("\x1B") < 0); ml.MemoryLog.Clear(); #endif Log.Info("Reset FG/BG: " + ESC.BG_RED + "BG RED" + ESC.GREEN + "FG REEN" + ESC.FG_RESET + "FG Reset" + ESC.BG_RESET + "BG Reset" ); #if ALOX_DBG_LOG Log.Verbose(ml.MemoryLog.ToString(mlPos)); UT_TRUE(ml.MemoryLog.IndexOf("\x1B") < 0); ml.MemoryLog.Clear(); #endif Log.Info("Reset FG/BG: " + ESC.BG_RED + "BG RED" + ESC.GREEN + "FG REEN" + ESC.BG_RESET + "BG Reset" + ESC.FG_RESET + "FG Reset" ); #if ALOX_DBG_LOG Log.Verbose(ml.MemoryLog.ToString(mlPos)); UT_TRUE(ml.MemoryLog.IndexOf("\x1B") < 0); ml.MemoryLog.Clear(); #endif Log.Info("Reset FG/BG: " + ESC.BG_RED + "BG RED" + ESC.GREEN + "FG REEN" + ESC.RESET + "All Reset" ); #if ALOX_DBG_LOG Log.Verbose(ml.MemoryLog.ToString(mlPos)); UT_TRUE(ml.MemoryLog.IndexOf("\x1B") < 0); ml.MemoryLog.Clear(); #endif Log.Info("Styles: " + ">>>" + ESC.BOLD + "Bold" + ESC.STYLE_RESET + "<<<" + ">>>" + ESC.ITALICS + "Italics" + ESC.STYLE_RESET + "<<<" + ">>>" + ESC.BOLD + ">>>" + ESC.ITALICS + "Bold/Italics" + ESC.STYLE_RESET + "+< Styles do not work in Windows consoles" ); #if ALOX_DBG_LOG Log.Verbose(ml.MemoryLog.ToString(mlPos)); UT_TRUE(ml.MemoryLog.IndexOf("\x1B") < 0); ml.MemoryLog.Clear(); #endif Log.Info("Reset Style/FG/BG: " + ESC.BOLD + "Bold" + ESC.BG_RED + "BG RED" + ESC.GREEN + "FG REEN" + ESC.BG_RESET + "BG Reset" + ESC.FG_RESET + "FG Reset" + ESC.STYLE_RESET + "Style Reset" ); #if ALOX_DBG_LOG Log.Verbose(ml.MemoryLog.ToString(mlPos)); UT_TRUE(ml.MemoryLog.IndexOf("\x1B") < 0); ml.MemoryLog.Clear(); #endif Log.Info("Reset Style/FG/BG: " + ESC.BOLD + "Bold" + ESC.BG_RED + "BG RED" + ESC.GREEN + "FG REEN" + ESC.RESET + "Reset All" ); #if ALOX_DBG_LOG Log.Verbose(ml.MemoryLog.ToString(mlPos)); UT_TRUE(ml.MemoryLog.IndexOf("\x1B") < 0); ml.MemoryLog.Clear(); #endif Log.Info("Reset Style/FG/BG: " + ESC.BOLD + "Bold" + ESC.BG_RED + "BG RED" + ESC.GREEN + "FG REEN" + ESC.STYLE_RESET + "Style Reset" + ESC.BG_RESET + "BG Reset" + ESC.FG_RESET + "FG Reset" + " +< This does not work on ANSI terminals: Styl reset, resets ALL here" ); #if ALOX_DBG_LOG Log.Verbose(ml.MemoryLog.ToString(mlPos)); UT_TRUE(ml.MemoryLog.IndexOf("\x1B") < 0); ml.MemoryLog.Clear(); #endif Log.Info("An URL: " + ESC.URL_START + "www.darwin.heaven" + ESC.URL_END + ", your resource for happyness!" ); #if ALOX_DBG_LOG Log.Verbose(ml.MemoryLog.ToString(mlPos)); UT_TRUE(ml.MemoryLog.IndexOf("\x1B") < 0); ml.MemoryLog.Clear(); #endif }