Exemplo n.º 1
0
        public JsonConfiguration(string fileName)
        {
            Inputs  = new List <IInput>();
            Filters = new List <IFilter>();
            Outputs = new List <IOutput>();

            string json = File.ReadAllText(fileName);
            //parse
            AntlrInputStream inputStream = new AntlrInputStream(json);
            var lexer = new LogstashconfigLexer(inputStream);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            var parser = new LogstashconfigParser(tokens);
            var tree   = parser.config();

            Console.WriteLine(tree.ToStringTree(parser));
            LogstashconfigVisitorImpl vistor = new LogstashconfigVisitorImpl();

            vistor.Visit(tree);
            var config = vistor.Config;

            KeyStoreLocation = "";


            foreach (Plugin input in config.Plugins["input"])
            {
                AddInput(input);
            }
            if (config.Plugins.ContainsKey("filter"))
            {
                foreach (Plugin filter in config.Plugins["filter"])
                {
                    AddFilter(filter);
                }
            }

            foreach (Plugin output in config.Plugins["output"])
            {
                AddOutput(output);
            }
        }
Exemplo n.º 2
0
        public JsonConfiguration(string fileName)
        {
            Inputs = new List<IInput>();
            Filters = new List<IFilter>();
            Outputs = new List<IOutput>();

            string json = File.ReadAllText(fileName);
            //parse
            AntlrInputStream inputStream = new AntlrInputStream(json);
            var lexer = new LogstashconfigLexer(inputStream);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            var parser = new LogstashconfigParser(tokens);
            var tree = parser.config();
            Console.WriteLine(tree.ToStringTree(parser));
            LogstashconfigVisitorImpl vistor = new LogstashconfigVisitorImpl();
            vistor.Visit(tree);
            var config = vistor.Config;

            KeyStoreLocation = "";


            foreach (Plugin input in config.Plugins["input"])
            {
                AddInput(input);
            }
            if (config.Plugins.ContainsKey("filter"))
            {
                foreach (Plugin filter in config.Plugins["filter"])
                {
                    AddFilter(filter);
                }
            }
                      
            foreach (Plugin output in config.Plugins["output"])
            {
                AddOutput(output);
            }
        }