コード例 #1
0
        public void TestInt64()
        {
            ConfigSource config = new ConfigSource();
            config.SetValue("key", 64L);

            Assert.AreEqual(64L, config.GetInt32("key"));
        }
コード例 #2
0
        public void TestIn32()
        {
            ConfigSource config = new ConfigSource();
            config.SetValue("key", 32);

            Assert.AreEqual(32, config.GetInt32("key"));
        }
コード例 #3
0
        public void GetChildValue()
        {
            ConfigSource config = new ConfigSource();
            ConfigSource child = config.AddChild("test.child");
            child.SetValue("value", 32);

            int value = config.GetInt32("test.child.value");
            Assert.AreEqual(32, value);
        }
コード例 #4
0
ファイル: DefaultLogger.cs プロジェクト: yuexiaoyun/cloudb
        public void Init(ConfigSource config)
        {
            string log_path_string  = config.GetString("path");
            string root_path_var    = config.GetString("rootPath");
            string read_only_access = config.GetString("readOnly");
            string debug_logs       = config.GetString("debugLogs");
            bool   read_only_bool   = false;

            if (read_only_access != null)
            {
                read_only_bool = String.Compare(read_only_access, "enabled", true) == 0;
            }
            bool debug_logs_bool = true;

            if (debug_logs != null)
            {
                debug_logs_bool = String.Compare(debug_logs, "enabled", true) == 0;
            }

            // Conditions for not initializing a log directory;
            //  1. Read only access is enabled
            //  2. log_path is empty or not set

            if (debug_logs_bool && !read_only_bool &&
                log_path_string != null && !log_path_string.Equals(""))
            {
                // First set up the debug information in this VM for the 'Debug' class.
                string log_path = ParseFileString(Environment.CurrentDirectory, root_path_var, log_path_string);
                // If the path doesn't exist the make it.
                if (!Directory.Exists(log_path))
                {
                    Directory.CreateDirectory(log_path);
                }

                LogWriter f_writer;
                String    dlog_file_name = "";
                try {
                    dlog_file_name = config.GetString("file");
                    string debug_log_file = Path.Combine(Path.GetFullPath(log_path), dlog_file_name);

                    // Allow log size to grow to 512k and allow 12 archives of the log
                    //TODO: make it configurable...
                    f_writer = new LogWriter(debug_log_file, 512 * 1024, 12);
                    f_writer.Write("**** Debug log started: " + DateTime.Now + " ****\n");
                    f_writer.Flush();
                } catch (IOException) {
                    throw new Exception("Unable to open debug file '" + dlog_file_name + "' in path '" + log_path + "'");
                }
                output = f_writer;
            }

            // If 'debug_logs=disabled', don't Write out any debug logs
            if (!debug_logs_bool)
            {
                // Otherwise set it up so the output from the logs goes to a PrintWriter
                // that doesn't do anything.  Basically - this means all log information
                // will get sent into a black hole.
                output = new EmptyTextWriter();
            }

            debug_level = config.GetInt32("level", -1);
            if (debug_level == -1)
            {
                // stops all the output
                debug_level = 255;
            }

            string format = config.GetString("format", null);

            if (format != null)
            {
                message_format = format;
            }
        }
コード例 #5
0
ファイル: DefaultLogger.cs プロジェクト: ikvm/cloudb
        public void Init(ConfigSource config)
        {
            string log_path_string = config.GetString("path");
            string root_path_var = config.GetString("rootPath");
            string read_only_access = config.GetString("readOnly");
            string debug_logs = config.GetString("debugLogs");
            bool read_only_bool = false;
            if (read_only_access != null) {
                read_only_bool = String.Compare(read_only_access, "enabled", true) == 0;
            }
            bool debug_logs_bool = true;
            if (debug_logs != null) {
                debug_logs_bool = String.Compare(debug_logs, "enabled", true) == 0;
            }

            // Conditions for not initializing a log directory;
            //  1. Read only access is enabled
            //  2. log_path is empty or not set

            if (debug_logs_bool && !read_only_bool &&
                log_path_string != null && !log_path_string.Equals("")) {
                // First set up the debug information in this VM for the 'Debug' class.
                string log_path = ParseFileString(Environment.CurrentDirectory, root_path_var, log_path_string);
                // If the path doesn't exist the make it.
                if (!Directory.Exists(log_path))
                    Directory.CreateDirectory(log_path);

                LogWriter f_writer;
                String dlog_file_name = "";
                try {
                    dlog_file_name = config.GetString("file");
                    string debug_log_file = Path.Combine(Path.GetFullPath(log_path), dlog_file_name);

                    // Allow log size to grow to 512k and allow 12 archives of the log
                    //TODO: make it configurable...
                    f_writer = new LogWriter(debug_log_file, 512 * 1024, 12);
                    f_writer.Write("**** Debug log started: " + DateTime.Now + " ****\n");
                    f_writer.Flush();
                } catch (IOException) {
                    throw new Exception("Unable to open debug file '" + dlog_file_name + "' in path '" + log_path + "'");
                }
                output = f_writer;
            }

            // If 'debug_logs=disabled', don't Write out any debug logs
            if (!debug_logs_bool) {
                // Otherwise set it up so the output from the logs goes to a PrintWriter
                // that doesn't do anything.  Basically - this means all log information
                // will get sent into a black hole.
                output = new EmptyTextWriter();
            }

            debug_level = config.GetInt32("level", -1);
            if (debug_level == -1)
                // stops all the output
                debug_level = 255;

            string format = config.GetString("format", null);
            if (format != null)
                message_format = format;
        }