From da6a8a36e243374e88ba1459d6173e7baf345354 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 3 Nov 2014 01:47:08 -0800 Subject: [PATCH] mon: move log config parsing into LogClient.h helper Signed-off-by: Sage Weil --- src/common/LogClient.cc | 39 +++++++++++++++++++++++++++++++++++++++ src/common/LogClient.h | 6 ++++++ src/mon/Monitor.cc | 29 ++--------------------------- 3 files changed, 47 insertions(+), 27 deletions(-) diff --git a/src/common/LogClient.cc b/src/common/LogClient.cc index 6b3c81f0c5a85..85350e24ac563 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 bbb07e094d17c..15d131f2f379c 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 900a616cbe721..ba4acbda02acc 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); -- 2.39.5