From: Sage Weil Date: Mon, 3 Nov 2014 09:47:08 +0000 (-0800) Subject: mon: move log config parsing into LogClient.h helper X-Git-Tag: v0.89~42^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=da6a8a36e243374e88ba1459d6173e7baf345354;p=ceph.git mon: move log config parsing into LogClient.h helper Signed-off-by: Sage Weil --- diff --git a/src/common/LogClient.cc b/src/common/LogClient.cc index 6b3c81f0c5a8..85350e24ac56 100644 --- a/src/common/LogClient.cc +++ b/src/common/LogClient.cc @@ -39,6 +39,45 @@ #include "common/config.h" #define dout_subsys ceph_subsys_monc + +int parse_log_client_options(CephContext *cct, + map &log_to_monitors, + map &log_to_syslog, + map &log_channels, + map &log_prios) +{ + ostringstream oss; + + int r = get_conf_str_map_helper(cct->_conf->clog_to_monitors, oss, + &log_to_monitors, CLOG_CHANNEL_DEFAULT); + if (r < 0) { + lderr(cct) << __func__ << " error parsing 'clog_to_monitors'" << dendl; + return r; + } + + r = get_conf_str_map_helper(cct->_conf->clog_to_syslog, oss, + &log_to_syslog, CLOG_CHANNEL_DEFAULT); + if (r < 0) { + lderr(cct) << __func__ << " error parsing 'clog_to_syslog'" << dendl; + return r; + } + + r = get_conf_str_map_helper(cct->_conf->clog_to_syslog_facility, oss, + &log_channels, CLOG_CHANNEL_DEFAULT); + if (r < 0) { + lderr(cct) << __func__ << " error parsing 'clog_to_syslog_facility'" << dendl; + return r; + } + + r = get_conf_str_map_helper(cct->_conf->clog_to_syslog_level, oss, + &log_prios, CLOG_CHANNEL_DEFAULT); + if (r < 0) { + lderr(cct) << __func__ << " error parsing 'clog_to_syslog_level'" << dendl; + return r; + } + return 0; +} + #undef dout_prefix #define dout_prefix _prefix(_dout, this) static ostream& _prefix(std::ostream *_dout, LogClient *logc) { diff --git a/src/common/LogClient.h b/src/common/LogClient.h index bbb07e094d17..15d131f2f379 100644 --- a/src/common/LogClient.h +++ b/src/common/LogClient.h @@ -31,6 +31,12 @@ struct Connection; class LogChannel; +int parse_log_client_options(CephContext *cct, + map &log_to_monitors, + map &log_to_syslog, + map &log_channels, + map &log_prios); + class LogClientTemp { public: diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 900a616cbe72..ba4acbda02ac 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -457,35 +457,10 @@ void Monitor::update_log_clients() map log_to_syslog; map log_channel; map log_prio; - ostringstream oss; - int r = get_conf_str_map_helper(g_conf->clog_to_monitors, oss, - &log_to_monitors, CLOG_CHANNEL_DEFAULT); - if (r < 0) { - derr << __func__ << " error parsing 'clog_to_monitors'" << dendl; - return; - } - - r = get_conf_str_map_helper(g_conf->clog_to_syslog, oss, - &log_to_syslog, CLOG_CHANNEL_DEFAULT); - if (r < 0) { - derr << __func__ << " error parsing 'clog_to_syslog'" << dendl; - return; - } - - r = get_conf_str_map_helper(g_conf->clog_to_syslog_facility, oss, - &log_channel, CLOG_CHANNEL_DEFAULT); - if (r < 0) { - derr << __func__ << " error parsing 'clog_to_syslog_facility'" << dendl; + if (parse_log_client_options(g_ceph_context, log_to_monitors, log_to_syslog, + log_channel, log_prio)) return; - } - - r = get_conf_str_map_helper(g_conf->clog_to_syslog_level, oss, - &log_prio, CLOG_CHANNEL_DEFAULT); - if (r < 0) { - derr << __func__ << " error parsing 'clog_to_syslog_level'" << dendl; - return; - } clog->update_config(log_to_monitors, log_to_syslog, log_channel, log_prio);