예제 #1
0
        static void Main(string[] args)
        {
            if (args.Length > 1)
            {
                if (args[0] == "-?")
                {
                    Console.WriteLine("to test logger \nusage:\n app.exe [-?] [-d] \n");
                    Environment.Exit(1);
                }
                else if (args[0] == "-d")
                {
                    dFlag = true;
                }
            }
            System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
            System.Version             ver = asm.GetName().Version;

            string MyName = asm.GetName().Name;

            MyName //= Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)
                += ".Logger.test.log";


            Thread.Sleep(2000);
            Logger = new LOGGER(IMPORTANCELEVEL.Warning, dFlag, MyName);

            for (int i = 0; i < 10; i++)
            {
                Logger.WriteLine(IMPORTANCELEVEL.Info, "this is {0} iteration", i);
                Console.Write("\rthis is {0:00} iteration", i);
                Thread.Sleep(500);
            }


            Thread.Sleep(100);
            Logger.Stop();
            Thread.Sleep(100);
            IMPORTANCELEVEL iL = IMPORTANCELEVEL.Spam;

            Console.Write("\nsecond logger in debug mode for {0} level\n\n", iL);

            //  Logger = new LOGGER(iL, true);
            Logger = new LOGGER(iL);

            Logger.WriteLine(IMPORTANCELEVEL.Warning, " to use debug mode of logger");

            Logger.cnslLvl = IMPORTANCELEVEL.Spam;
            Logger.cnslLvl = IMPORTANCELEVEL.Ignore;
            Logger.cnslLvl = IMPORTANCELEVEL.Error;
            Logger.cnslLvl = IMPORTANCELEVEL.Info;
            Logger.cnslLvl = IMPORTANCELEVEL.FatalError;
            Logger.cnslLvl = IMPORTANCELEVEL.Debug;
            Logger.cnslLvl = IMPORTANCELEVEL.Warning;
            Logger.cnslLvl = IMPORTANCELEVEL.Stats;

            for (uint i = 0; i < 9; i++)
            {
                Logger.WriteLine(LOGGER.uitoLvl(i),
                                 "this is {0} iteration {1}>={2} =={3}  ",
                                 i, LOGGER.uitoLvl(i), Logger.cnslLvl, LOGGER.uitoLvl(i) >= Logger.cnslLvl);
                Thread.Sleep(500);
            }


//						Logger.cnslLvl = IMPORTANCELEVEL.Info;

            for (uint i = 0; i < 0; i++)
            {
                Logger.WriteLine(LOGGER.uitoLvl(i), "this is {0} iteration {1}", i, LOGGER.uitoLvl(i));
            }

            Logger.WriteLine(IMPORTANCELEVEL.Spam, " no any message");
            Logger.WriteLine(IMPORTANCELEVEL.Warning, " to  finish of usage debug mode of logger");
            Logger.Dispose();
            Logger.WriteLine(IMPORTANCELEVEL.Warning, " to  debug");
        }