Ejemplo n.º 1
0
        public void ShouldFindFormatHandler()
        {
            FormatHandlerLibraryModule module;

            module = new FormatHandlerLibraryModule(NullLogger.Instance, new MockedDirectoryEnumerator(5), new MockedFormatHandlerLoader(), new RegexBuilder());
            module.LoadDirectory("Path");
            Assert.AreEqual("Path1", module.GetFormatHandler("Path1").Name);
            Assert.AreEqual("Path2", module.GetFormatHandler("Path2").Name);
            Assert.AreEqual("Path3", module.GetFormatHandler("Path3").Name);
            Assert.AreEqual("Path4", module.GetFormatHandler("Path4").Name);
        }
Ejemplo n.º 2
0
        public void ShouldNotThrowWhenPassingNullFileName()
        {
            FormatHandlerLibraryModule module;

            module = new FormatHandlerLibraryModule(NullLogger.Instance, new MockedDirectoryEnumerator(5), new MockedFormatHandlerLoader(), new RegexBuilder());
            module.LoadDirectory("Path");
            Assert.AreEqual("Default handler", module.GetFormatHandler(null).Name);
        }
Ejemplo n.º 3
0
        public void ShouldNotFindFormatHandlerButReturnADefault()
        {
            FormatHandlerLibraryModule module;

            module = new FormatHandlerLibraryModule(NullLogger.Instance, new MockedDirectoryEnumerator(5), new MockedFormatHandlerLoader(), new RegexBuilder());
            module.LoadDirectory("Path");
            Assert.AreEqual("Default handler", module.GetFormatHandler("Path5").Name);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            ILogger logger;
            IPatternLibraryModule       patternLibraryModule;
            IInlineFormatLibraryModule  inlineFormatLibraryModule;
            IFormatHandlerLibraryModule formatHandlerLibraryModule;
            IStringMatcherFactoryModule stringMatcherFactoryModule;
            LogFileLoaderModule         dumper;

            /*ILineReader lineReader;
            *  ILineBuilder lineBuilder;
            *  ILogBuilder logBuilder;*/
            LogParser logParser;

            FormatHandler formatHandler;

            if (args.Length == 0)
            {
                return;
            }

            logger = new FileLogger(new DefaultLogFormatter(), "LogInspectCLI.log");

            patternLibraryModule       = new PatternLibraryModule(logger, new DirectoryEnumerator(), new PatternLibLoader());
            inlineFormatLibraryModule  = new InlineFormatLibraryModule(logger, new DirectoryEnumerator(), new InlineColoringRuleLibLoader());
            formatHandlerLibraryModule = new FormatHandlerLibraryModule(logger, new DirectoryEnumerator(), new FormatHandlerLoader(), patternLibraryModule);

            patternLibraryModule.LoadDirectory(Properties.Settings.Default.PatternsFolder);
            inlineFormatLibraryModule.LoadDirectory(Properties.Settings.Default.InlineFormatsFolder);
            formatHandlerLibraryModule.LoadDirectory(Properties.Settings.Default.FormatHandlersFolder);

            stringMatcherFactoryModule = new StringMatcherFactoryModule(logger, patternLibraryModule);
            formatHandler = formatHandlerLibraryModule.GetFormatHandler(args[0]);


            /*lineBuilder = new LineBuilder(stringMatcherFactoryModule.CreateStringMatcher(formatHandler.NameSpace, formatHandler.DiscardLinePatterns));
             * logBuilder = new LogBuilder(
             *      stringMatcherFactoryModule.CreateStringMatcher(formatHandler.NameSpace, formatHandler.Rules.Where(item => item.Discard).Select(item => item.GetPattern())),
             *      stringMatcherFactoryModule.CreateStringMatcher(formatHandler.NameSpace, formatHandler.AppendLineToPreviousPatterns),
             *      stringMatcherFactoryModule.CreateStringMatcher(formatHandler.NameSpace, formatHandler.AppendLineToNextPatterns)
             *      );
             * logParser = new LogParser(formatHandler.Columns);
             * logParser.Add(patternLibraryModule.Build(formatHandler.NameSpace, formatHandler.Rules.Select(item => item.GetPattern()), true));
             *
             *
             * using (FileStream stream = new FileStream(args[0], FileMode.Open))
             * {
             *      lineReader = new FileLineReader(stream);
             *      dumper = new LogFileLoaderModule(logger,lineReader,lineBuilder,logBuilder,logParser);
             *      foreach(Event ev in dumper.Load())
             *      {
             *              Console.WriteLine(string.Join("	", ev.Properties));
             *      }
             * }*/

            Console.ReadLine();
        }