public void Log_Domain_IniFile() { UT_INIT(); // Without priorities { // create iniFile IniFile iniFile = new IniFile("*"); // don't read iniFile.Save(ALox.ConfigCategoryName, "TESTML_FORMAT", "%Sp"); iniFile.Save(ALox.ConfigCategoryName, "T_LOX_TESTML_VERBOSITY", "/DOM_VERB = VerboseXX ;" // xx is allowed! + "/DOM_INFO = Info ;" + "/DOM_WARN = WARNING ;" + "/DOM_ERR = erRor ;" + "/DOM_OFF = off ;" + "/DOM_OFF2 = xxx ;" + "/ATSTART* = Info ;" + "*ATEND = Info ;" + "*SUBSTR* = Info ;" + "/OVERWRITE = Info ;" ); ALIB.Config.InsertPlugin(iniFile, Configuration.PrioIniFile); // test Lox lox = new Lox("T_LOX", false); lox.SetVerbosity(Lox.CreateConsoleLogger("CONSOLE"), Verbosity.Verbose); lox.SetVerbosity("CONSOLE", Verbosity.Verbose, ALox.InternalDomains); // pre-create one of the domains to test if loggers added later get config for existing domains lox.Verbose("DOM_INFO", "test"); MemoryLogger ml = new MemoryLogger("TESTML"); lox.SetVerbosity(ml, Verbosity.Off); lox.Info("test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Error("NOSETTING", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("DOM_VERB", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("DOM_INFO", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("DOM_INFO", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Info("DOM_WARN", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Warning("DOM_WARN", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Warning("DOM_ERR", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Error("DOM_ERR", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Error("DOM_OFF", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Error("DOM_OFF2", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("ATSTART", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("ATSTART", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("ATSTARTXX", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("ATSTARTXX", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("XXATSTART", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("XXATSTART", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("XATSTARTX", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("XATSTARTX", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("ATEND", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("ATEND", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("ATENDXX", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("ATENDXX", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("XXATEND", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("XXATEND", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("XATENDX", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("XATENDX", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("SUBSTR", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("SUBSTR", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("SUBSTRXX", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("SUBSTRXX", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("XXSUBSTR", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("XXSUBSTR", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("XSUBSTRX", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("XSUBSTRX", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; // overwrite config lox.Verbose("/OVERWRITE", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("/OVERWRITE", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.SetVerbosity(ml, Verbosity.Warning, "/OVERWRITE"); // does not overwrite lox.Verbose("/OVERWRITE", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("/OVERWRITE", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.SetVerbosity(ml, Verbosity.Warning, "/OVERWRITE", 1000); // does overwrite lox.Verbose("/OVERWRITE", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("/OVERWRITE", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Warning("/OVERWRITE", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; // overwrite non-config lox.Error("/A", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Error("/A/B", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Error("/A/C", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.SetVerbosity(ml, Verbosity.Info, "/A/B", Lox.PrioSource - 1); // does not overwrite lox.Verbose("/A/B", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("/A/B", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.SetVerbosity(ml, Verbosity.Info, "/A/B", Lox.PrioSource); // does overwrite lox.Verbose("/A/B", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("/A/B", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.SetVerbosity(ml, Verbosity.Info, "/A/B", Lox.PrioSource + 1); // one higher lox.Verbose("/A/B", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("/A/B", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.SetVerbosity(ml, Verbosity.Verbose, "/A"); lox.Verbose("/A", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("/A/B", "test"); UT_EQ(0, ml.CntLogs); ml.CntLogs = 0; lox.Info("/A/B", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; lox.Verbose("/A/C", "test"); UT_EQ(1, ml.CntLogs); ml.CntLogs = 0; //lox.LogConfig( "", Verbosity.Info, "Configuration now is:" ); ml.MemoryLog._(); ml.AutoSizes.Reset(); ALIB.Config.RemovePlugin(iniFile); lox.RemoveLogger(ml); lox.RemoveLogger("CONSOLE"); } }
public void Lox_LogLevelSetting() { UT_INIT(); Lox lox = new Lox("ReleaseLox"); TextLogger logger = Lox.CreateConsoleLogger(null); lox.SetDomain("TLLS_DF", Scope.Method); int logLinesBefore = logger.CntLogs; // Test Verbosity setting lox.SetVerbosity(logger, Verbosity.Verbose, ""); lox.Verbose("This Verbose line should be logged"); lox.Info("This Info line should be logged"); lox.Warning("This WARN line should be logged"); lox.Error("This Error line should be logged"); lox.SetVerbosity(logger, Verbosity.Info, ""); lox.Verbose("This Verbose line should NOT be logged. !!!!!Test Error!!!!!"); lox.Info("This Info line should be logged"); lox.Warning("This Warning line should be logged"); lox.Error("This Error line should be logged"); lox.SetVerbosity(logger, Verbosity.Warning, ""); lox.Verbose("This Verbose line should NOT be logged. !!!!!Test Error!!!!!"); lox.Info("This Info line should NOT be logged. !!!!!Test Error!!!!!"); lox.Warning("This Warning line should be logged"); lox.Error("This Error line should be logged"); lox.SetVerbosity(logger, Verbosity.Error, ""); lox.Verbose("This Verbose line should NOT be logged. !!!!!Test Error!!!!!"); lox.Info("This Info line should NOT be logged. !!!!!Test Error!!!!!"); lox.Warning("This Warning line should NOT be logged. !!!!!Test Error!!!!!"); lox.Error("This Error line should be logged"); lox.SetVerbosity(logger, Verbosity.Off, ""); lox.Verbose("This Verbose line should NOT be logged. !!!!!Test Error!!!!!"); lox.Info("This Info line should NOT be logged. !!!!!Test Error!!!!!"); lox.Warning("This Warning line should NOT be logged. !!!!!Test Error!!!!!"); lox.Error("This Error line should NOT be logged. !!!!!Test Error!!!!!"); lox.SetVerbosity(logger, Verbosity.Verbose, "/TLLS"); lox.Verbose("/TLLS", "This Verbose line should be logged"); lox.Info("/TLLS", "This Info line should be logged"); lox.Warning("/TLLS", "This WARN line should be logged"); lox.Error("/TLLS", "This Error line should be logged"); lox.SetVerbosity(logger, Verbosity.Info, "/TLLS"); lox.Verbose("/TLLS", "This Verbose line should NOT be logged. !!!!!Test Error!!!!!"); lox.Info("/TLLS", "This Info line should be logged"); lox.Warning("/TLLS", "This Warning line should be logged"); lox.Error("/TLLS", "This Error line should be logged"); lox.SetVerbosity(logger, Verbosity.Warning, "/TLLS"); lox.Verbose("/TLLS", "This Verbose line should NOT be logged. !!!!!Test Error!!!!!"); lox.Info("/TLLS", "This Info line should NOT be logged. !!!!!Test Error!!!!!"); lox.Warning("/TLLS", "This Warning line should be logged"); lox.Error("/TLLS", "This Error line should be logged"); lox.SetVerbosity(logger, Verbosity.Error, "/TLLS"); lox.Verbose("/TLLS", "This Verbose line should NOT be logged. !!!!!Test Error!!!!!"); lox.Info("/TLLS", "This Info line should NOT be logged. !!!!!Test Error!!!!!"); lox.Warning("/TLLS", "This Warning line should NOT be logged. !!!!!Test Error!!!!!"); lox.Error("/TLLS", "This Error line should be logged"); lox.SetVerbosity(logger, Verbosity.Off, "/TLLS"); lox.Verbose("/TLLS", "This Verbose line should NOT be logged. !!!!!Test Error!!!!!"); lox.Info("/TLLS", "This Info line should NOT be logged. !!!!!Test Error!!!!!"); lox.Warning("/TLLS", "This Warning line should NOT be logged. !!!!!Test Error!!!!!"); lox.Error("/TLLS", "This Error line should NOT be logged. !!!!!Test Error!!!!!"); UT_EQ((uint)20, logger.CntLogs - logLinesBefore); lox.RemoveLogger(logger); }