Exemplo n.º 1
0
        public void CompositeConsoleLogger()
        {
            ConfigSource config = new ConfigSource();
            config.SetValue("logger.composite.type", "composite");
            config.SetValue("logger.composite.1.type", "simple-console");
            config.SetValue("logger.composite.2.type", "simple-console");

            Logger.Init(config);
            Logger logger = Logger.GetLogger("composite");
            Assert.IsInstanceOf(typeof(CompositeLogger), logger.BaseLogger);

            logger.Info("Print a simple message that must be written in the console twice");
        }
Exemplo n.º 2
0
        public void CompositeConsoleLogger()
        {
            ConfigSource config = new ConfigSource();

            config.SetValue("logger.composite.type", "composite");
            config.SetValue("logger.composite.1.type", "simple-console");
            config.SetValue("logger.composite.2.type", "simple-console");

            Logger.Init(config);
            Logger logger = Logger.GetLogger("composite");

            Assert.IsInstanceOf(typeof(CompositeLogger), logger.BaseLogger);

            logger.Info("Print a simple message that must be written in the console twice");
        }
Exemplo n.º 3
0
        public void TestInt64()
        {
            ConfigSource config = new ConfigSource();
            config.SetValue("key", 64L);

            Assert.AreEqual(64L, config.GetInt32("key"));
        }
Exemplo n.º 4
0
        public void TestIn32()
        {
            ConfigSource config = new ConfigSource();
            config.SetValue("key", 32);

            Assert.AreEqual(32, config.GetInt32("key"));
        }
Exemplo n.º 5
0
        protected virtual void Config(ConfigSource config)
        {
            if (storeType == StoreType.FileSystem)
            {
                if (Directory.Exists(TestPath))
                {
                    Directory.Delete(TestPath, true);
                }

                Directory.CreateDirectory(path);

                config.SetValue("node_directory", path);
            }

            config.SetValue("logger." + Logger.NetworkLoggerName + ".type", "simple-console");
            Logger.Init(config);
            Assert.IsInstanceOf(typeof(SimpleConsoleLogger), Logger.Network.BaseLogger);
        }
Exemplo n.º 6
0
        public void ConfigureNetworkLogger()
        {
            ConfigSource config = new ConfigSource();
            config.SetValue("logger.network.type", "simple-console");

            Logger.Init(config);
            Logger logger = Logger.Network;
            Assert.IsInstanceOf(typeof(SimpleConsoleLogger), logger.BaseLogger);
        }
Exemplo n.º 7
0
        public void ConfigureDefaultDebugger()
        {
            ConfigSource config = new ConfigSource();
            config.SetValue("logger.foo.type", "default");

            Logger.Init(config);
            Logger logger = Logger.GetLogger("foo");
            Assert.IsInstanceOf(typeof(DefaultLogger), logger.BaseLogger);
        }
Exemplo n.º 8
0
        public void DefaultWithoutExplicitSpec()
        {
            ConfigSource config = new ConfigSource();
            config.SetValue("logger.format", "[{Time}] - {Source} - {Message]");

            Logger.Init(config);
            Logger logger = Logger.GetLogger();
            Assert.IsInstanceOf(typeof(DefaultLogger), logger.BaseLogger);
            Assert.AreEqual("[{Time}] - {Source} - {Message]", logger.Config.GetString("format"));
        }
        public void Load(ConfigSource config, Stream input)
        {
            if (!input.CanRead)
                throw new ArgumentException("Cannot read from the stream.", "input");

            Util.Properties properties = new Util.Properties();
            properties.Load(input);
            foreach(KeyValuePair<object, object> pair in properties) {
                config.SetValue((string)pair.Key, (string)pair.Value);
            }
        }
Exemplo n.º 10
0
        public void ConfigureSimpleConsoleLogger()
        {
            ConfigSource config = new ConfigSource();
            config.SetValue("logger.foo.type", "simple-console");

            Logger.Init(config);
            Logger logger = Logger.GetLogger("foo");
            Assert.IsInstanceOf(typeof(SimpleConsoleLogger), logger.BaseLogger);

            logger.Info("Printing a log message");
        }
Exemplo n.º 11
0
        public void ConfigureNetworkLogger()
        {
            ConfigSource config = new ConfigSource();

            config.SetValue("logger.network.type", "simple-console");

            Logger.Init(config);
            Logger logger = Logger.Network;

            Assert.IsInstanceOf(typeof(SimpleConsoleLogger), logger.BaseLogger);
        }
Exemplo n.º 12
0
        public void ConfigureDefaultDebugger()
        {
            ConfigSource config = new ConfigSource();

            config.SetValue("logger.foo.type", "default");

            Logger.Init(config);
            Logger logger = Logger.GetLogger("foo");

            Assert.IsInstanceOf(typeof(DefaultLogger), logger.BaseLogger);
        }
Exemplo n.º 13
0
        public void DefaultWithoutExplicitSpec()
        {
            ConfigSource config = new ConfigSource();

            config.SetValue("logger.format", "[{Time}] - {Source} - {Message]");

            Logger.Init(config);
            Logger logger = Logger.GetLogger();

            Assert.IsInstanceOf(typeof(DefaultLogger), logger.BaseLogger);
            Assert.AreEqual("[{Time}] - {Source} - {Message]", logger.Config.GetString("format"));
        }
Exemplo n.º 14
0
        public void ConfigureSimpleConsoleLogger()
        {
            ConfigSource config = new ConfigSource();

            config.SetValue("logger.foo.type", "simple-console");

            Logger.Init(config);
            Logger logger = Logger.GetLogger("foo");

            Assert.IsInstanceOf(typeof(SimpleConsoleLogger), logger.BaseLogger);

            logger.Info("Printing a log message");
        }
Exemplo n.º 15
0
        public void TestString()
        {
            ConfigSource config = new ConfigSource();
            config.SetValue("key", "value");

            Assert.AreEqual("value", config.GetString("key"));
        }
Exemplo n.º 16
0
        protected virtual void Config(ConfigSource config)
        {
            if (storeType == NetworkStoreType.FileSystem) {
                if (Directory.Exists(TestPath))
                    Directory.Delete(TestPath, true);

                Directory.CreateDirectory(path);

                config.SetValue("node_directory", path);
            }

            config.SetValue("logger." + Logger.NetworkLoggerName + ".type", "simple-console");
            Logger.Init(config);
            Assert.IsInstanceOf(typeof(SimpleConsoleLogger), Logger.Network.BaseLogger);
        }