Пример #1
0
 protected FLProgramCheck(Type inType, Type outType) : base(inType, outType)
 {
     if (!CreatedLoggers.ContainsKey(GetType()))
     {
         ADLLogger <LogType> l = new ADLLogger <LogType>(Settings, GetType().Name);
         CreatedLoggers[GetType()] = l;
     }
 }
        private void RefreshProjects()
        {
            cbProjects.Items.Clear();
            lbLogger.Items.Clear();
            ReadOnlyDictionary <IProjectDebugConfig, List <ADLLogger> > map = ADLLogger.GetReadOnlyLoggerMap();

            cbProjects.Items.AddRange(map.Keys.ToArray());
        }
Пример #3
0
 /// <summary>
 /// Protected Constructor
 /// </summary>
 /// <param name="keys">Keys of the Command</param>
 /// <param name="helpText">Optional Help Text</param>
 /// <param name="defaultCommand">Flag that indicates if this command is a default command.</param>
 protected AbstractCommand(string[] keys, string helpText = "No Help Text Available",
                           bool defaultCommand            = false)
 {
     Logger         = new ADLLogger <LogType>("Cmd: " + (keys == null || keys.Length == 0 ? "Unmapped" : keys[0]));
     CommandKeys    = keys;
     HelpText       = helpText;
     DefaultCommand = defaultCommand;
 }
Пример #4
0
        public void ADL_Debug_RemoveAllPrefixes_Test()
        {
            ADLLogger logger = new ADLLogger("UnitTest");
            BitMask   bm     = new BitMask(2 | 8);

            logger.AddPrefixForMask(bm, "HELLO");
            logger.RemoveAllPrefixes();
            Assert.True(logger.GetAllPrefixes().Count == 0);
        }
Пример #5
0
        public void ADL_Debug_RemoveAllPrefixes_Test()
        {
            ADLLogger logger = new ADLLogger(InternalADLProjectDebugConfig.Settings, "UnitTest");
            BitMask   bm     = new BitMask(2 | 8);

            logger.AddPrefixForMask(bm, "HELLO");
            logger.RemoveAllPrefixes();
            Assert.True(logger.GetAllPrefixes().Count == 0);
        }
Пример #6
0
 /// <summary>
 /// Protected Constructor
 /// </summary>
 /// <param name="action">Command Implementation</param>
 /// <param name="keys">Keys of the Command</param>
 /// <param name="helpText">Optional Help Text</param>
 /// <param name="defaultCommand">Flag that indicates if this command is a default command.</param>
 protected AbstractCommand(Action <StartupArgumentInfo, string[]> action, string[] keys,
                           string helpText = "No Help Text Available", bool defaultCommand = false)
 {
     Logger = new ADLLogger <LogType>(CommandRunnerDebugConfig.Settings,
                                      "Cmd: " + (keys == null || keys.Length == 0 ? "Unmapped" : keys[0]));
     CommandAction  = action;
     CommandKeys    = keys;
     HelpText       = helpText;
     DefaultCommand = defaultCommand;
 }
Пример #7
0
        public void ADL_Debug_SetAllPrefixes_Test()
        {
            //Flag is required to find tags made up of unique masks(example: 2|8)
            Debug.PrefixLookupMode = PrefixLookupSettings.AddPrefixIfAvailable;

            ADLLogger logger = new ADLLogger(InternalADLProjectDebugConfig.Settings, "UnitTest");

            logger.SetAllPrefixes("Hello", "HELLO1", "HOLA2");

            Assert.True(logger.GetMaskPrefix(1) == "Hello");
            Assert.True(logger.GetMaskPrefix(2) == "HELLO1");
            Assert.True(logger.GetMaskPrefix(4) == "HOLA2");
        }
 private void cbProjects_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbProjects.SelectedIndex != -1)
     {
         ReadOnlyDictionary <IProjectDebugConfig, List <ADLLogger> > map = ADLLogger.GetReadOnlyLoggerMap();
         IProjectDebugConfig config = (IProjectDebugConfig)cbProjects.SelectedItem;
         lbLogger.Items.Clear();
         lbLogger.Items.AddRange(map[config].ToArray());
         ignoreSeveritySet           = true;
         cbMinSeverity.SelectedIndex =
             cbMinSeverity.Items.IndexOf(((Verbosity)config.GetMinSeverity()).ToString());
         ignoreSeveritySet = false;
     }
 }
Пример #9
0
        public void ADL_Debug_RemovePrefixForMask_Test()
        {
            ADLLogger logger = new ADLLogger("UnitTest");
            BitMask   bm     = new BitMask(2 | 8);

            logger.AddPrefixForMask(bm, "HELLO");
            logger.RemovePrefixForMask(bm);


            Debug.AdlEnabled = false;

            logger.AddPrefixForMask(bm, "AAA");
            logger.RemovePrefixForMask(bm);
            Debug.AdlEnabled = true;

            Assert.True(logger.GetAllPrefixes().Count == 0);
        }
Пример #10
0
        public void ADL_Debug_GetPrefixMask_Test()
        {
            ADLLogger logger = new ADLLogger("UnitTest");

            logger.SetAllPrefixes("Hello", "HELLO1", "HOLA2");
            if (logger.GetPrefixMask("Hello", out BitMask bm))
            {
                Assert.True(bm == 1);
            }
            if (logger.GetPrefixMask("HELLO1", out bm))
            {
                Assert.True(bm == 2);
            }
            if (logger.GetPrefixMask("HOLA2", out bm))
            {
                Assert.True(bm == 4);
            }
        }
Пример #11
0
        public void ADL_Debug_AddPrefixForMask_Test()
        {
            //Flag is required to find tags made up of unique masks(example: 2|8)
            Debug.PrefixLookupMode =
                PrefixLookupSettings.AddPrefixIfAvailable | PrefixLookupSettings.DeconstructMaskToFind;

            ADLLogger logger = new ADLLogger(InternalADLProjectDebugConfig.Settings, "UnitTest");

            BitMask bm = new BitMask(2 | 8);

            logger.AddPrefixForMask(bm | 4, "Test");
            logger.AddPrefixForMask(bm | 4, "Test");
            logger.RemoveAllPrefixes();

            logger.AddPrefixForMask(bm, "HELLO");
            bool ret = logger.GetMaskPrefix(bm) == "HELLO";

            Assert.True(ret);
        }
Пример #12
0
        public void ADL_Debug_GetAllPrefixes_Test()
        {
            ADLLogger logger = new ADLLogger("UnitTest");

            //Flag is required to find tags made up of unique masks(example: 2|8)
            Debug.PrefixLookupMode = PrefixLookupSettings.Addprefixifavailable;


            logger.SetAllPrefixes("Hello", "HELLO1", "HOLA2");

            Assert.True(logger.GetAllPrefixes().Count == 3);

            logger.RemoveAllPrefixes();

            Debug.AdlEnabled = false;
            logger.SetAllPrefixes("Hello", "HELLO1", "HOLA2");

            Assert.True(logger.GetAllPrefixes().Count == 3);
            Debug.AdlEnabled = true;
        }
Пример #13
0
        public void ADL_Debug_Log_Test()
        {
            LogTextStream lts = new LogTextStream(new PipeStream())
            {
                AddTimeStamp = false
            };


            Debug.PrefixLookupMode = PrefixLookupSettings.Noprefix;
            Assert.True(Debug.PrefixLookupMode == PrefixLookupSettings.Noprefix);


            ADLLogger logger = new ADLLogger("UnitTest");


            Debug.AddOutputStream(lts);
            logger.Log(1, "ffffffffff");

            byte[] buf = new byte[lts.Length];
            lts.Read(buf, 0, buf.Length);
            string s = Debug.TextEncoding.GetString(buf);

            Assert.EndsWith("ffffffffff\n", s); //ADL is appending the \n when using LogTextStreams


            logger.Log(1, "ffffffffff");
            Debug.AdlEnabled = false;
            logger.Log(1, "ffffffffff");
            Debug.AdlEnabled = true;
            buf = new byte[lts.Length];
            lts.Read(buf, 0, buf.Length);
            s = Debug.TextEncoding.GetString(buf);

            Assert.EndsWith("ffffffffff\n", s);


            Debug.PrefixLookupMode = PrefixLookupSettings.Addprefixifavailable | PrefixLookupSettings.Bakeprefixes;

            logger.Log(2 | 4, "CODE COVERAGE");
            logger.Log(2 | 4, "CODE COVERAGE");
        }
Пример #14
0
        public void ADL_Debug_AddPrefixForMask_Test()
        {
            //Flag is required to find tags made up of unique masks(example: 2|8)
            Debug.PrefixLookupMode =
                PrefixLookupSettings.Addprefixifavailable | PrefixLookupSettings.Deconstructmasktofind;

            ADLLogger logger = new ADLLogger("UnitTest");

            BitMask bm = new BitMask(2 | 8);

            Debug.AdlEnabled = false;
            logger.AddPrefixForMask(bm | 4, "Test");
            logger.AddPrefixForMask(bm | 4, "Test");
            logger.RemoveAllPrefixes();

            logger.AddPrefixForMask(bm, "HELLO");
            Debug.AdlEnabled = true;
            bool ret = logger.GetMaskPrefix(bm) == "HELLO";

            Assert.True(ret);
        }
Пример #15
0
        public void ADL_Debug_Log_Test()
        {
            LogTextStream lts = new LogTextStream(new PipeStream())
            {
                AddTimeStamp = false
            };


            Debug.PrefixLookupMode = PrefixLookupSettings.NoPrefix;
            Assert.True(Debug.PrefixLookupMode == PrefixLookupSettings.NoPrefix);


            ADLLogger logger = new ADLLogger(InternalADLProjectDebugConfig.Settings, "UnitTest");


            Debug.AddOutputStream(lts);
            logger.Log(1, "ffffffffff", 0);

            byte[] buf = new byte[lts.Length];
            lts.Read(buf, 0, buf.Length);
            string s = Debug.TextEncoding.GetString(buf);

            Assert.True(s.EndsWith("ffffffffff\n")); //ADL is appending the \n when using LogTextStreams


            logger.Log(1, "ffffffffff", 0);
            buf = new byte[lts.Length];
            lts.Read(buf, 0, buf.Length);
            s = Debug.TextEncoding.GetString(buf);

            Assert.True(s.EndsWith("ffffffffff\n"));


            Debug.PrefixLookupMode = PrefixLookupSettings.AddPrefixIfAvailable | PrefixLookupSettings.BakePrefixes;

            logger.Log(2 | 4, "CODE COVERAGE", 0);
            logger.Log(2 | 4, "CODE COVERAGE", 0);
        }
Пример #16
0
        public void ADL_Debug_GetMaskPrefix_Test()
        {
            ADLLogger logger = new ADLLogger(InternalADLProjectDebugConfig.Settings, "UnitTest");

            //Flag is required to find tags made up of unique masks(example: 2|8)
            Debug.PrefixLookupMode = PrefixLookupSettings.AddPrefixIfAvailable;

            logger.SetAllPrefixes("Hello", "HELLO1", "HOLA2");
            BitMask bm = 2;

            Assert.True(logger.GetMaskPrefix(bm) == "HELLO1");

            Debug.PrefixLookupMode = PrefixLookupSettings.AddPrefixIfAvailable | PrefixLookupSettings.OnlyOnePrefix;

            bm = 32;
            Assert.False(logger.GetMaskPrefix(bm) == "HELLO1");

            Debug.PrefixLookupMode = PrefixLookupSettings.AddPrefixIfAvailable | PrefixLookupSettings.BakePrefixes |
                                     PrefixLookupSettings.DeconstructMaskToFind;

            bm = 32;
            Assert.False(logger.GetMaskPrefix(bm) == "HELLO1");
        }
Пример #17
0
        public void ADL_Debug_GetMaskPrefix_Test()
        {
            ADLLogger logger = new ADLLogger("UnitTest");

            //Flag is required to find tags made up of unique masks(example: 2|8)
            Debug.PrefixLookupMode = PrefixLookupSettings.Addprefixifavailable;

            logger.SetAllPrefixes("Hello", "HELLO1", "HOLA2");
            BitMask bm = 2;

            Assert.True(logger.GetMaskPrefix(bm) == "HELLO1");

            Debug.PrefixLookupMode = PrefixLookupSettings.Addprefixifavailable | PrefixLookupSettings.Onlyoneprefix;

            bm = 32;
            Assert.False(logger.GetMaskPrefix(bm) == "HELLO1");

            Debug.PrefixLookupMode = PrefixLookupSettings.Addprefixifavailable | PrefixLookupSettings.Bakeprefixes |
                                     PrefixLookupSettings.Deconstructmasktofind;

            bm = 32;
            Assert.False(logger.GetMaskPrefix(bm) == "HELLO1");
        }
Пример #18
0
 protected AHandler()
 {
     Logger = new ADLLogger <LogType>(PackageHandlerDebugConfig.Settings, "Handler: " + GetType().Name);
 }
Пример #19
0
 protected AHandler()
 {
     Logger = new ADLLogger <LogType>("Handler: " + GetType().Name);
 }
Пример #20
0
        private static void Main(string[] args)
        {
            //int[] iterations = new[] { 100, 100_000, 1_000_000, 10_000_000, 100_000_000 };

            //for (int i = 0; i < iterations.Length; i++)
            //{
            //    Console.WriteLine("ITERATIONS: " + iterations[i]);
            //    ILTests(iterations[i]);
            //}
            //return;
            //Console.ReadLine();

            Debug.DefaultInitialization();

            ExtPPDebugConfig.Settings.MinSeverity             = Verbosity.Level1;
            OpenFLDebugConfig.Settings.MinSeverity            = Verbosity.Level1;
            OpenCLDebugConfig.Settings.MinSeverity            = Verbosity.Level1;
            AssemblyGeneratorDebugConfig.Settings.MinSeverity = Verbosity.Level1;
            EngineDebugConfig.Settings.MinSeverity            = Verbosity.Level1;

            ADLLogger <LogType> logger = new ADLLogger <LogType>(new ProjectDebugConfig("Testing Project", -1, 10,
                                                                                        PrefixLookupSettings.AddPrefixIfAvailable));


            logger.Log(LogType.Log, "Available Consoles: " + Consoles.Keys.Unpack(", "), 1);
            logger.Log(LogType.Log, "Type \"exit\" to exit", 1);

            if (args.Length != 0)
            {
                if (Consoles.ContainsKey(args[0]))
                {
                    string[] arg = new string[args.Length - 1];

                    for (int i = 1; i < args.Length; i++)
                    {
                        arg[i - 1] = args[i];
                    }

                    Consoles[args[0]].Run(arg);

                    Runner.RemoveAllCommands();

                    return;
                }
            }

            while (true)
            {
                Console.Write("root>");
                string   line    = Console.ReadLine();
                string[] command = line.Split(new[] { ' ' });
                if (command[0] == "exit")
                {
                    break;
                }

                if (command[0] == "file")
                {
                    command = File.ReadAllText(command[1])
                              .Split(new[] { ' ', '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray();
                }

                if (Consoles.ContainsKey(command[0]))
                {
                    string[] arg = new string[command.Length - 1];

                    for (int i = 1; i < command.Length; i++)
                    {
                        arg[i - 1] = command[i];
                    }

                    Consoles[command[0]].Run(arg);

                    Runner.RemoveAllCommands();
                }

                if (Exit)
                {
                    break;
                }
            }
        }
Пример #21
0
        public void Run(string[] args)
        {
            Debug.OnConfigCreate += ProjectDebugConfig_OnConfigCreate;

            AbstractCommand.MIN_COMMAND_SEVERITY = 0;

            Runner r = new Runner();

            r._AddCommand(
                new SetDataCommand(
                    s => NoDialog = true,
                    new[] { "--yes" },
                    "Answer all dialogs with Yes"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => Verbosity = int.Parse(strings.First()),
                    new[] { "--verbosity", "-v" },
                    "The Verbosity Level (lower = less logs)"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => CheckTypes =
                        (FLProgramCheckType)Enum.Parse(
                            typeof(FLProgramCheckType),
                            strings.First(),
                            true
                            ),
                    new[] { "--checks", "-checks" },
                    $"Program Check Profile. (Available: {Enum.GetNames(typeof(FLProgramCheckType)).Unpack(", ")})"
                    )
                );
            r._AddCommand(new DefaultHelpCommand(true));
            AddCommands(r);

            Debug.DefaultInitialization();
            r._RunCommands(args);
            if (AbortRun)
            {
                Console.ReadLine();
                return;
            }

            foreach (KeyValuePair <IProjectDebugConfig, List <ADLLogger> > keyValuePair in ADLLogger.GetReadOnlyLoggerMap()
                     )
            {
                keyValuePair.Key.SetMinSeverity(Verbosity);
            }

            OpenFLDebugConfig.Settings.SetMinSeverity(Verbosity);

            FLData.InitializeFL(NoDialog, CheckTypes);

            BeforeRun();

            DoRun(args);

            AfterRun();

            Debug.OnConfigCreate -= ProjectDebugConfig_OnConfigCreate;
        }
Пример #22
0
 protected FLProgramCheck(Type inType, Type outType) : base(inType, outType)
 {
     Logger = new ADLLogger <LogType>(OpenFLDebugConfig.Settings, GetType().Name);
 }
Пример #23
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="errorMessage">The message why this exception occurred</param>
 /// <param name="inner">Inner exeption</param>
 public Byt3Exception(string errorMessage, Exception inner) : base(errorMessage, inner)
 {
     Logger = new ADLLogger <DebugChannel>(GetType().Name);
 }
Пример #24
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="errorMessage">The message why this exception occurred</param>
 /// <param name="inner">Inner exeption</param>
 public Byt3Exception(string errorMessage, Exception inner) : base(errorMessage, inner)
 {
     Logger = new ADLLogger <LogType>(Settings, GetType().Name);
 }
Пример #25
0
 internal static void Crash(this ADLLogger <DebugChannel> logger, Byt3Exception exception, bool throwEx)
 {
     throw exception;
 }