From 712541cdefcc9614e5a79f628358f205ceda6e55 Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Tue, 11 Mar 2014 15:05:44 +0530 Subject: logging: Make logger and log format configurable through cli Change-Id: Ic4b701a6621578848ff67ae4ecb5a10b5f32f93b BUG: 1075611 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/7372 Tested-by: Gluster Build System Reviewed-by: Krishnan Parthasarathi Reviewed-by: Vijay Bellur --- xlators/debug/io-stats/src/io-stats.c | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'xlators/debug') diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index 9e48a7c6e..d63fbb26c 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -2666,9 +2666,13 @@ reconfigure (xlator_t *this, dict_t *options) struct ios_conf *conf = NULL; int ret = -1; char *sys_log_str = NULL; + char *log_format_str = NULL; + char *logger_str = NULL; int sys_log_level = -1; char *log_str = NULL; int log_level = -1; + int log_format = -1; + int logger = -1; if (!this || !this->private) goto out; @@ -2696,6 +2700,18 @@ reconfigure (xlator_t *this, dict_t *options) gf_log_set_loglevel (log_level); } + GF_OPTION_RECONF ("logger", logger_str, options, str, out); + if (logger_str) { + logger = gf_check_logger (logger_str); + gf_log_set_logger (logger); + } + + GF_OPTION_RECONF ("log-format", log_format_str, options, str, out); + if (log_format_str) { + log_format = gf_check_log_format (log_format_str); + gf_log_set_logformat (log_format); + } + ret = 0; out: gf_log (this->name, GF_LOG_DEBUG, "reconfigure returning %d", ret); @@ -2727,6 +2743,10 @@ init (xlator_t *this) { struct ios_conf *conf = NULL; char *sys_log_str = NULL; + char *logger_str = NULL; + char *log_format_str = NULL; + int logger = -1; + int log_format = -1; int sys_log_level = -1; char *log_str = NULL; int log_level = -1; @@ -2785,6 +2805,19 @@ init (xlator_t *this) gf_log_set_loglevel (log_level); } + GF_OPTION_INIT ("logger", logger_str, str, out); + if (logger_str) { + logger = gf_check_logger (logger_str); + gf_log_set_logger (logger); + } + + GF_OPTION_INIT ("log-format", log_format_str, str, out); + if (log_format_str) { + log_format = gf_check_log_format (log_format_str); + gf_log_set_logformat (log_format); + } + + this->private = conf; ret = 0; out: @@ -3027,6 +3060,40 @@ struct volume_options options[] = { .value = { "DEBUG", "WARNING", "ERROR", "INFO", "CRITICAL", "NONE", "TRACE"} }, + { .key = {"logger"}, + .type = GF_OPTION_TYPE_STR, + .value = { GF_LOGGER_GLUSTER_LOG, GF_LOGGER_SYSLOG} + }, + { .key = {"client-logger"}, + .type = GF_OPTION_TYPE_STR, + .default_value = GF_LOGGER_GLUSTER_LOG, + .description = "Changes the logging sub-system to log to, for the " + "clients", + .value = { GF_LOGGER_GLUSTER_LOG, GF_LOGGER_SYSLOG} + }, + { .key = {"brick-logger"}, + .type = GF_OPTION_TYPE_STR, + .default_value = GF_LOGGER_GLUSTER_LOG, + .description = "Changes the logging sub-system to log to, for the " + "bricks", + .value = { GF_LOGGER_GLUSTER_LOG, GF_LOGGER_SYSLOG} + }, + { .key = {"log-format"}, + .type = GF_OPTION_TYPE_STR, + .value = { GF_LOG_FORMAT_NO_MSG_ID, GF_LOG_FORMAT_WITH_MSG_ID} + }, + { .key = {"client-log-format"}, + .type = GF_OPTION_TYPE_STR, + .default_value = GF_LOG_FORMAT_WITH_MSG_ID, + .description = "Changes log format for the clients", + .value = { GF_LOG_FORMAT_NO_MSG_ID, GF_LOG_FORMAT_WITH_MSG_ID} + }, + { .key = {"brick-log-format"}, + .type = GF_OPTION_TYPE_STR, + .default_value = GF_LOG_FORMAT_WITH_MSG_ID, + .description = "Changes the log format for the bricks", + .value = { GF_LOG_FORMAT_NO_MSG_ID, GF_LOG_FORMAT_WITH_MSG_ID} + }, { .key = {NULL} }, }; -- cgit