public void Log_Data()
        {
            UT_INIT();

            Log.AddDebugLogger();
            Log.SetVerbosity(Log.DebugLogger, Verbosity.Verbose, ALox.InternalDomains);
            Log.SetDomain("Data", Scope.Method);

            // LogData Constructors
            {
                LogData ld;
                AString asnull = new AString();
                ld = new LogData(              ); UT_EQ(asnull, ld.StringValue); UT_EQ(0, ld.IntegerValue); UT_TRUE(ld.ObjectValue == null);
                ld = new LogData(3); UT_EQ(asnull, ld.StringValue); UT_EQ(3, ld.IntegerValue); UT_TRUE(ld.ObjectValue == null);
                ld = new LogData(3, this); UT_EQ(asnull, ld.StringValue); UT_EQ(3, ld.IntegerValue); UT_TRUE(ld.ObjectValue == this);
                ld = new LogData("ABC"); UT_EQ("ABC", ld.StringValue); UT_EQ(0, ld.IntegerValue); UT_TRUE(ld.ObjectValue == null);
                ld = new LogData("ABC", 0, this); UT_EQ("ABC", ld.StringValue); UT_EQ(0, ld.IntegerValue); UT_TRUE(ld.ObjectValue == this);
                ld = new LogData("ABC", 3); UT_EQ("ABC", ld.StringValue); UT_EQ(3, ld.IntegerValue); UT_TRUE(ld.ObjectValue == null);
                ld = new LogData("ABC", 3, this); UT_EQ("ABC", ld.StringValue); UT_EQ(3, ld.IntegerValue); UT_TRUE(ld.ObjectValue == this);
            }

            // without key
            Log.Store(null, Scope.Global);
            Log.Store(new LogData("Replaced"), Scope.Global);
            Log.Store(null, Scope.Global);
            Log.Store(null, Scope.Global);
            Log.Store(new LogData("Replaced"), Scope.Global);
            Log.Store(new LogData("Global"), Scope.Global);
            Log.Store(new LogData("Replaced"), Scope.ThreadOuter);
            Log.Store(new LogData("ThreadOuter"), Scope.ThreadOuter);
            Log.Store(new LogData("Replaced"), Scope.Path, 1);
            Log.Store(new LogData("Path1"), Scope.Path, 1);
            Log.Store(new LogData("Replaced"), Scope.Path);
            Log.Store(new LogData("Path"), Scope.Path);
            Log.Store(new LogData("Replaced"), Scope.Filename);
            Log.Store(new LogData("FileName"), Scope.Filename);
            Log.Store(new LogData("Replaced"), Scope.Method);
            Log.Store(new LogData("Method"), Scope.Method);
            Log.Store(new LogData("Replaced"), Scope.ThreadInner);
            Log.Store(new LogData("ThreadInner"), Scope.ThreadInner);

            LogData data = null;

            data = Log.Retrieve(Scope.Global); UT_EQ("Global", data.StringValue);
            data = Log.Retrieve(Scope.ThreadOuter); UT_EQ("ThreadOuter", data.StringValue);
            data = Log.Retrieve(Scope.Path, 1); UT_EQ("Path1", data.StringValue);
            data = Log.Retrieve(Scope.Path); UT_EQ("Path", data.StringValue);
            data = Log.Retrieve(Scope.Filename); UT_EQ("FileName", data.StringValue);
            data = Log.Retrieve(Scope.Method); UT_EQ("Method", data.StringValue);
            data = Log.Retrieve(Scope.ThreadInner); UT_EQ("ThreadInner", data.StringValue);

            // wit key
            Log.Store(new LogData("Replaced"), "mykey", Scope.Global);
            Log.Store(new LogData("Global"), "mykey", Scope.Global);
            Log.Store(new LogData("Replaced"), "mykey", Scope.ThreadOuter);
            Log.Store(new LogData("ThreadOuter"), "mykey", Scope.ThreadOuter);
            Log.Store(new LogData("Replaced"), "mykey", Scope.Path, 1);
            Log.Store(new LogData("Path1"), "mykey", Scope.Path, 1);
            Log.Store(new LogData("Replaced"), "mykey", Scope.Path);
            Log.Store(new LogData("Path"), "mykey", Scope.Path);
            Log.Store(new LogData("Replaced"), "mykey", Scope.Filename);
            Log.Store(new LogData("FileName"), "mykey", Scope.Filename);
            Log.Store(new LogData("Replaced"), "mykey", Scope.Method);
            Log.Store(new LogData("Method"), "mykey", Scope.Method);
            Log.Store(new LogData("Replaced"), "mykey", Scope.ThreadInner);
            Log.Store(new LogData("ThreadInner"), "mykey", Scope.ThreadInner);


            data = Log.Retrieve("mykey", Scope.Global); UT_EQ("Global", data.StringValue);
            data = Log.Retrieve("mykey", Scope.ThreadOuter); UT_EQ("ThreadOuter", data.StringValue);
            data = Log.Retrieve("mykey", Scope.Path, 1); UT_EQ("Path1", data.StringValue);
            data = Log.Retrieve("mykey", Scope.Path); UT_EQ("Path", data.StringValue);
            data = Log.Retrieve("mykey", Scope.Filename); UT_EQ("FileName", data.StringValue);
            data = Log.Retrieve("mykey", Scope.Method); UT_EQ("Method", data.StringValue);
            data = Log.Retrieve("mykey", Scope.ThreadInner); UT_EQ("ThreadInner", data.StringValue);


            // threaded
            Log.Store(new LogData("Main Thread Data"), Scope.ThreadOuter);
            Log.Store(new LogData("Main Thread Data, keyed"), "mykey", Scope.ThreadOuter);


            Thread thread = new Thread(new ThreadStart(StoreDataTestThreadRun));

            thread.Start();
            while (thread.IsAlive)
            {
                ;
            }
            ALIB.SleepMicros(1);

            data = Log.Retrieve(Scope.ThreadOuter); UT_EQ("Main Thread Data", data.StringValue);
            data = Log.Retrieve("mykey", Scope.ThreadOuter); UT_EQ("Main Thread Data, keyed", data.StringValue);
        }
        public void Log_LogOnce()
        {
            UT_INIT();

            Log.AddDebugLogger();
            MemoryLogger ml = new MemoryLogger();

            Log.SetVerbosity(ml, Verbosity.Verbose);
            Log.SetVerbosity(Log.DebugLogger, Verbosity.Verbose, ALox.InternalDomains);
            Log.SetDomain("ONCE", Scope.Method);

            //-------------------- associated to scope method-----------------
            for (int i = 0; i < 5; i++)
            {
                Log.Once(Verbosity.Info, "Once(Scope method) 1x", Scope.Method);
            }
            Log.Once(Verbosity.Info, "Once(Scope method) 1x", Scope.Method);

            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;


            //-------------------- associated to scope filename -----------------
            for (int i = 0; i < 5; i++)
            {
                Log.Once("Subdom", Verbosity.Info, "Once(Scope filename) 4x", Scope.Filename, 0, 4);
                logOnceMethod();
            }
            Log.Once(Verbosity.Info, "Once(Scope filename) 4x", Scope.Filename, 0, 4);

            UT_EQ(4, ml.CntLogs); ml.CntLogs = 0;

            //-------------------- associated to scope thread -----------------
            Log.Once(Verbosity.Info, "Once(Scope.ThreadOuter) 2x - main thread", Scope.ThreadOuter, 0, 2);
            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;
            Thread thread = new Thread(new ThreadStart(LogOnceTestThreadRun));

            thread.Start();
            while (thread.IsAlive)
            {
                ;
            }
            ALIB.SleepMicros(1);
            UT_EQ(2, ml.CntLogs); ml.CntLogs = 0;
            Log.Once(Verbosity.Info, "Once(Scope.ThreadOuter) 2x - main thread", Scope.ThreadOuter, 0, 2);
            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;
            Log.Once(Verbosity.Info, "Once(Scope.ThreadOuter) 2x - main thread", Scope.ThreadOuter, 0, 2);
            UT_EQ(0, ml.CntLogs); ml.CntLogs = 0;
            Log.Once(Verbosity.Info, "Once(Scope.ThreadOuter) 2x - main thread", Scope.ThreadOuter, 0, 2);
            UT_EQ(0, ml.CntLogs); ml.CntLogs = 0;

            // different group
            Log.Once("Once(group, Scope.ThreadOuter) 2x - main thread", "group", Scope.ThreadOuter, 0, 1);
            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;
            Log.Once("Once(group, Scope.ThreadOuter) 2x - main thread", "group", Scope.ThreadOuter, 0, 1);
            UT_EQ(0, ml.CntLogs); ml.CntLogs = 0;

            //-------------------- associated to line (using group interface)  -----------------
            for (int i = 0; i < 5; i++)
            {
                Log.Once(Verbosity.Info, "Once(line) 1x");
            }
            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;

            for (int i = 0; i < 5; i++)
            {
                Log.Once(Verbosity.Info, "Once(line other) 2x", "", 2);
            }
            UT_EQ(2, ml.CntLogs); ml.CntLogs = 0;

            for (int i = 0; i < 5; i++)
            {
                Log.Once(Verbosity.Info, "Once(line other) 1x", "", 1);
            }
            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;

            for (int i = 0; i < 5; i++)
            {
                Log.Once(Verbosity.Info, "Once(line other) 0x", "", 0);
            }
            UT_EQ(0, ml.CntLogs); ml.CntLogs = 0;

            for (int i = 0; i < 5; i++)
            {
                Log.Once("Once(line) Just msg and number", 2);
            }
            UT_EQ(2, ml.CntLogs); ml.CntLogs = 0;

            for (int i = 0; i < 5; i++)
            {
                Log.Once("Once(line) Just msg ");
            }
            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;

            //-------------------- associated to group -----------------
            for (int i = 0; i < 5; i++)
            {
                Log.Once(Verbosity.Info, "Once(\"a group\") 1x", "a group");
            }
            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;
            Log.Once(Verbosity.Info, "Once(\"a group\") 1x but tricked up", "a group", 2);
            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;


            Log.Once(Verbosity.Info, "Once(\"a group\") 1x", "a group");
            UT_EQ(0, ml.CntLogs); ml.CntLogs = 0;

            Log.Once(Verbosity.Info, "Once(\"b group\") 1x", "b group");
            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;

            Log.Once(Verbosity.Info, "Once(\"b group\") 1x", "b group");
            UT_EQ(0, ml.CntLogs); ml.CntLogs = 0;

            Log.Once(Verbosity.Info, "Once(\"c group\") 2x", "c group", 2);
            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;

            Log.Once(Verbosity.Info, "Once(\"c group\") 2x", "c group", 2);
            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;

            Log.Once(Verbosity.Info, "Once(\"c group\") 2x", "c group", 2);
            UT_EQ(0, ml.CntLogs); ml.CntLogs = 0;

            Log.Once(Verbosity.Info, "Once(\"a group\") 1x", "a group");
            UT_EQ(0, ml.CntLogs); ml.CntLogs = 0;

            Log.Once(Verbosity.Info, "Once(\"b group\") 1x", "b group");
            UT_EQ(0, ml.CntLogs); ml.CntLogs = 0;

            Log.Once(Verbosity.Info, "Once(\"c group\") 2x", "c group", 2);
            UT_EQ(0, ml.CntLogs); ml.CntLogs = 0;

            // AString
            Log.Once(new AString("Once with AString"));
            UT_EQ(1, ml.CntLogs); ml.CntLogs = 0;


            //-------------------- Log every Nth -----------------
            for (int i = 0; i < 10; i++)
            {
                Log.Once(Verbosity.Info, "Every 2nd ", -2);
            }
            UT_EQ(5, ml.CntLogs); ml.CntLogs = 0;

            for (int i = 0; i < 10; i++)
            {
                Log.Once(Verbosity.Info, "Every 3rd ", -3);
            }

            UT_EQ(4, ml.CntLogs); ml.CntLogs = 0;
        }