示例#1
0
        public void Init()
        {
            Metric.Config.WithHttpEndpoint("http://localhost:2581/").WithSystemCounters();

            //XXX use config to get this info
            var registryFactory = LogRegistryFactory.Create();

            var parserFactory = LogParserFactory.GetParserForFileExtension("xml");

            IPrinterFactory printerFactory;

            if (config.ExtraConfigs != null && config.ExtraConfigs.ContainsKey("printToFile") && !string.IsNullOrWhiteSpace(config.ExtraConfigs["printToFile"]))
            {
                // Note: this just sets a default. Configs can change the file
                printerFactory = PrinterFactory.CrateFileFactory(config.ExtraConfigs["printToFile"]);
            }
            else
            {
                printerFactory = PrinterFactory.CrateConsoleFactory();
            }

            registry = registryFactory.Create();

            logFileParser = parserFactory.Create(registry, config);
            printer       = printerFactory.Create(registry, config);
        }