public void Log_RelativeDomains() { UT_INIT(); Lox lox= new Lox( "ReleaseLox" ); MemoryLogger ml= new MemoryLogger(); lox.SetVerbosity ( ml, Verbosity.Verbose ); ml.MetaInfo.Format._()._("@%D#"); lox.SetDomain( "/D1/D2/D3", Scope.Method ); lox.Info( "D4" , "" ); UT_EQ( "@/D1/D2/D3/D4#" , ml.MemoryLog ); ml.MemoryLog._(); ml.AutoSizes.Reset(); lox.Info( "./D4" , "" ); UT_EQ( "@/D1/D2/D3/D4#" , ml.MemoryLog ); ml.MemoryLog._(); ml.AutoSizes.Reset(); lox.Info( "../D4" , "" ); UT_EQ( "@/D1/D2/D4#" , ml.MemoryLog ); ml.MemoryLog._(); ml.AutoSizes.Reset(); lox.Info( ".././.././D4" , "" ); UT_EQ( "@/D1/D4#" , ml.MemoryLog ); ml.MemoryLog._(); ml.AutoSizes.Reset(); lox.Info( "../../../../../D4" , "" ); UT_EQ( "@/D4#" , ml.MemoryLog ); ml.MemoryLog._(); ml.AutoSizes.Reset(); lox.Info( "../D4/../D5" , "" ); UT_EQ( "@/D1/D2/D5#" , ml.MemoryLog ); ml.MemoryLog._(); ml.AutoSizes.Reset(); lox.RemoveLogger( ml ); }
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 ); }
public void Lox_ScopeDomains() { UT_INIT(); // we have tell alox to include more directories in the scope path Log.ClearSourcePathTrimRules( Reach.Global, false); Log.SetSourcePathTrimRule( "*/alox/src.cs/", Inclusion.Exclude ); Lox lox= new Lox( "ReleaseLox" ); TextLogger consoleLogger= Lox.CreateConsoleLogger(); MemoryLogger ml= new MemoryLogger(); ml.MetaInfo.Format._()._("@%D#"); lox.SetVerbosity(ml, Verbosity.Verbose ); lox.SetVerbosity(consoleLogger, Verbosity.Verbose ); lox.SetVerbosity(consoleLogger, Verbosity.Verbose, ALox.InternalDomains ); // scope global lox.SetDomain( "REPLACE", Scope.Global ); lox.Info( "" , "" ); SDCHECK_RL( "@/REPLACE#" ,ml ); lox.SetDomain( "GLOBAL", Scope.Global ); lox.Info( "" , "" ); SDCHECK_RL( "@/GLOBAL#" ,ml ); lox.SetDomain( null, Scope.Global ); lox.Info( "" , "" ); SDCHECK_RL( "@/#" ,ml ); // scope source lox.SetDomain( "REPLACE", Scope.Filename ); lox.Info( "" , "" ); CICHECK_RL( "@/REPLACE#" ,ml ); lox.SetDomain( "FILE", Scope.Filename ); lox.Info( "" , "" ); CICHECK_RL( "@/FILE#" ,ml ); // scope method lox.SetDomain( "REPLACE", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/FILE/REPLACE#" ,ml ); lox.SetDomain( "Method", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/FILE/METHOD#" ,ml ); lox.SetDomain( "/ABS", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/ABS#" ,ml ); // unset method with null lox.SetDomain( null, Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/FILE#" ,ml ); // unset method with "" lox.SetDomain( "/METHOD", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/METHOD#" ,ml ); lox.SetDomain( "", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/FILE#" ,ml ); lox.SetDomain( "Method", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/FILE/METHOD#" ,ml ); // source path lox.SetDomain( "REPLACE", Scope.Path ); lox.Info( "" , "" ); CICHECK_RL( "@/REPLACE/FILE/METHOD#" ,ml ); lox.SetDomain( "PATH", Scope.Path ); lox.Info( "" , "" ); CICHECK_RL( "@/PATH/FILE/METHOD#" ,ml ); lox.SetDomain( "REPLACE", Scope.Path, 1 ); lox.Info( "" , "" ); CICHECK_RL( "@/REPLACE/PATH/FILE/METHOD#" ,ml ); lox.SetDomain( "PO1", Scope.Path, 1 ); lox.Info( "" , "" ); CICHECK_RL( "@/PO1/PATH/FILE/METHOD#" ,ml ); lox.SetDomain( "REPLACE", Scope.Path, 2 ); lox.Info( "" , "" ); CICHECK_RL( "@/REPLACE/PO1/PATH/FILE/METHOD#",ml ); lox.SetDomain( "PO2", Scope.Path, 2 ); lox.Info( "" , "" ); CICHECK_RL( "@/PO2/PO1/PATH/FILE/METHOD#" ,ml ); lox.SetDomain( "GLOBAL", Scope.Global ); lox.Info( "" , "" ); CICHECK_RL( "@/GLOBAL/PO2/PO1/PATH/FILE/METHOD#" , ml ); // remove all previous scope domains lox.SetDomain( "", Scope.Global ); lox.SetDomain( "", Scope.Path ); lox.SetDomain( "", Scope.Path ,1 ); lox.SetDomain( "", Scope.Path ,2 ); lox.SetDomain( "", Scope.Filename ); lox.SetDomain( "", Scope.Method ); lox.Info( "LOC", "" ); SDCHECK_RL( "@/LOC#" ,ml ); // Thread-related lox.SetDomain( "T_O", Scope.ThreadOuter ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_O#" ,ml ); lox.SetDomain( "GL", Scope.Global ); lox.Info( "" , "" ); SDCHECK_RL( "@/GL/T_O#" ,ml ); lox.SetDomain( "MET", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/GL/T_O/MET#" ,ml ); lox.Info( "LOC", "" ); CICHECK_RL( "@/GL/T_O/MET/LOC#" ,ml ); lox.SetDomain( "T_I", Scope.ThreadInner ); lox.Info( "" , "" ); CICHECK_RL( "@/GL/T_O/MET/T_I#" ,ml ); lox.Info( "LOC", "" ); CICHECK_RL( "@/GL/T_O/MET/LOC/T_I#" ,ml ); lox.SetDomain( "T_O2", Scope.ThreadOuter ); lox.Info( "" , "" ); CICHECK_RL( "@/GL/T_O/T_O2/MET/T_I#" ,ml ); lox.SetDomain( "T_I2", Scope.ThreadInner ); lox.Info( "" , "" ); CICHECK_RL( "@/GL/T_O/T_O2/MET/T_I/T_I2#" ,ml ); lox.SetDomain( "/T_O3",Scope.ThreadOuter ); lox.Info( "" , "" ); CICHECK_RL( "@/T_O3/MET/T_I/T_I2#" ,ml ); lox.SetDomain( "/T_I3",Scope.ThreadInner ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_I3#" ,ml ); lox.SetDomain( "", Scope.Method ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_I3#" ,ml ); lox.SetDomain ( "" ,Scope.ThreadInner ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_O3/T_I/T_I2#" ,ml ); lox.RemoveThreadDomain( "T_IXX",Scope.ThreadInner ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_O3/T_I/T_I2#" ,ml ); lox.RemoveThreadDomain( "T_I" ,Scope.ThreadInner ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_O3/T_I2#" ,ml ); lox.RemoveThreadDomain( "" ,Scope.ThreadInner ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_O3/T_I2#" ,ml ); lox.SetDomain ( "" ,Scope.ThreadInner ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_O3#" ,ml ); lox.SetDomain ( "" ,Scope.ThreadOuter ); lox.Info( "" , "" ); SDCHECK_RL( "@/GL/T_O/T_O2#" ,ml ); lox.SetDomain ( "T_O3", Scope.ThreadOuter ); lox.Info( "" , "" ); SDCHECK_RL( "@/GL/T_O/T_O2/T_O3#",ml ); lox.RemoveThreadDomain( "T_O2" ,Scope.ThreadOuter ); lox.Info( "" , "" ); SDCHECK_RL( "@/GL/T_O/T_O3#" ,ml ); lox.RemoveThreadDomain( "T_O" ,Scope.ThreadOuter ); lox.Info( "" , "" ); SDCHECK_RL( "@/GL/T_O3#" ,ml ); lox.SetDomain ( "" ,Scope.ThreadOuter ); lox.Info( "" , "" ); SDCHECK_RL( "@/GL#" ,ml ); lox.SetDomain ( "" ,Scope.Global ); lox.Info( "" , "" ); SDCHECK_RL( "@/#" ,ml ); // second thread Thread thread= new Thread( new ParameterizedThreadStart( DomainTestThreadRun_RL ) ); lox.SetDomain( "THIS_THREAD", Scope.ThreadOuter ); lox.SetDomain( "OTHER_THREAD", Scope.ThreadOuter, thread ); thread.Start( lox ); while( thread.IsAlive ) ALIB.SleepMillis(1); UT_EQ( "@/OTHER_THREAD/DTT#", ml.MemoryLog ); ml.MemoryLog._(); ml.AutoSizes.Reset(); lox.Info( "ME", "" ); UT_EQ( "@/THIS_THREAD/ME#" , ml.MemoryLog ); ml.MemoryLog._(); ml.AutoSizes.Reset(); // cleanup lox.RemoveLogger( consoleLogger ); lox.RemoveLogger( ml ); }