From c09036aca22f28df578409d97627d35ec3793b5c Mon Sep 17 00:00:00 2001 From: xinxin shu Date: Tue, 5 Aug 2014 06:53:36 +0800 Subject: [PATCH] enable info_log_level config option for rocksdb Signed-off-by: xinxin shu --- src/common/config_opts.h | 1 + src/os/RocksDBStore.cc | 21 ++++++++++++++++++++- src/os/RocksDBStore.h | 5 ++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index d3b25350f595d..6712f51e58d81 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -598,6 +598,7 @@ OPTION(rocksdb_disableDataSync, OPT_BOOL, true) // if true, data files are not s OPTION(rocksdb_disableWAL, OPT_BOOL, false) // diable write ahead log OPTION(rocksdb_num_levels, OPT_INT, 0) // number of levels for this database OPTION(rocksdb_wal_dir, OPT_STR, "") // rocksdb write ahead log file +OPTION(rocksdb_info_log_level, OPT_STR, "info") // info log level : debug , info , warn, error, fatal /** * osd_client_op_priority and osd_recovery_op_priority adjust the relative diff --git a/src/os/RocksDBStore.cc b/src/os/RocksDBStore.cc index 916951b066793..8b1b6dbceeb33 100644 --- a/src/os/RocksDBStore.cc +++ b/src/os/RocksDBStore.cc @@ -41,6 +41,7 @@ int RocksDBStore::init() options.num_levels = g_conf->rocksdb_num_levels; options.disableWAL = g_conf->rocksdb_disableWAL; options.wal_dir = g_conf->rocksdb_wal_dir; + options.info_log_level = g_conf->rocksdb_info_log_level; return 0; } @@ -87,10 +88,12 @@ int RocksDBStore::do_open(ostream &out, bool create_if_missing) ldoptions.error_if_exists = options.error_if_exists; ldoptions.paranoid_checks = options.paranoid_checks; ldoptions.create_if_missing = create_if_missing; - if (options.log_file.length()) { rocksdb::Env *env = rocksdb::Env::Default(); env->NewLogger(options.log_file, &ldoptions.info_log); + ldoptions.info_log->SetInfoLogLevel((rocksdb::InfoLogLevel)get_info_log_level(options.info_log_level)); + } else { + ldoptions.info_log_level = (rocksdb::InfoLogLevel)get_info_log_level(options.info_log_level); } if(options.disableDataSync) ldoptions.disableDataSync = options.disableDataSync; @@ -191,6 +194,22 @@ int RocksDBStore::submit_transaction_sync(KeyValueDB::Transaction t) logger->inc(l_rocksdb_txns); return s.ok() ? 0 : -1; } +int RocksDBStore::get_info_log_level(string info_log_level) +{ + if (info_log_level == "debug") { + return 0; + } else if (info_log_level == "info") { + return 1; + } else if (info_log_level == "warn") { + return 2; + } else if (info_log_level == "error") { + return 3; + } else if (info_log_level == "fatal") { + return 4; + } else { + return 1; + } +} RocksDBStore::RocksDBTransactionImpl::RocksDBTransactionImpl(RocksDBStore *_db) { diff --git a/src/os/RocksDBStore.h b/src/os/RocksDBStore.h index 1122abc38bd78..318f259bcbf4c 100644 --- a/src/os/RocksDBStore.h +++ b/src/os/RocksDBStore.h @@ -96,6 +96,7 @@ public: void compact_range_async(const string& prefix, const string& start, const string& end) { compact_range_async(combine_strings(prefix, start), combine_strings(prefix, end)); } + int get_info_log_level(string info_log_level); /** * options_t: Holds options which are minimally interpreted @@ -132,6 +133,7 @@ public: string log_file; string wal_dir; + string info_log_level; options_t() : write_buffer_size(0), //< 0 means default @@ -148,7 +150,8 @@ public: level0_stop_writes_trigger(0), disableDataSync(false), disableWAL(false), - num_levels(0) + num_levels(0), + info_log_level("info") {} } options; -- 2.39.5