Example #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");
        }
Example #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");
        }
Example #3
0
        public void TestInt64()
        {
            ConfigSource config = new ConfigSource();
            config.SetValue("key", 64L);

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

            Assert.AreEqual(32, config.GetInt32("key"));
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
            }
        }
Example #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");
        }
Example #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);
        }
Example #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);
        }
Example #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"));
        }
Example #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");
        }
Example #15
0
        public void TestString()
        {
            ConfigSource config = new ConfigSource();
            config.SetValue("key", "value");

            Assert.AreEqual("value", config.GetString("key"));
        }
Example #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);
        }