summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2014-03-11 15:05:44 +0530
committerVijay Bellur <vbellur@redhat.com>2014-04-11 18:00:54 -0700
commit712541cdefcc9614e5a79f628358f205ceda6e55 (patch)
treed2ba17083d16f1cacc80c7498ba0534d7ef16baf /xlators
parente73af16885f6d11ebcb225edb4d12214ceeba74c (diff)
logging: Make logger and log format configurable through cli
Change-Id: Ic4b701a6621578848ff67ae4ecb5a10b5f32f93b BUG: 1075611 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/7372 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/debug/io-stats/src/io-stats.c67
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c87
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-set.c22
3 files changed, 170 insertions, 6 deletions
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} },
};
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 783958279..0b3a8d099 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1328,6 +1328,44 @@ sys_loglevel_option_handler (volgen_graph_t *graph,
}
static int
+logger_option_handler (volgen_graph_t *graph, struct volopt_map_entry *vme,
+ void *param)
+{
+ char *role = NULL;
+ struct volopt_map_entry vme2 = {0,};
+
+ role = (char *) param;
+
+ if (strcmp (vme->option, "!logger") != 0 ||
+ !strstr (vme->key, role))
+ return 0;
+
+ memcpy (&vme2, vme, sizeof (vme2));
+ vme2.option = "logger";
+
+ return basic_option_handler (graph, &vme2, NULL);
+}
+
+static int
+log_format_option_handler (volgen_graph_t *graph, struct volopt_map_entry *vme,
+ void *param)
+{
+ char *role = NULL;
+ struct volopt_map_entry vme2 = {0,};
+
+ role = (char *) param;
+
+ if (strcmp (vme->option, "!log-format") != 0 ||
+ !strstr (vme->key, role))
+ return 0;
+
+ memcpy (&vme2, vme, sizeof (vme2));
+ vme2.option = "log-format";
+
+ return basic_option_handler (graph, &vme2, NULL);
+}
+
+static int
volgen_graph_set_xl_options (volgen_graph_t *graph, dict_t *dict)
{
int32_t ret = -1;
@@ -1379,6 +1417,12 @@ server_spec_option_handler (volgen_graph_t *graph,
if (!ret)
ret = sys_loglevel_option_handler (graph, vme, "brick");
+ if (!ret)
+ ret = logger_option_handler (graph, vme, "brick");
+
+ if (!ret)
+ ret = log_format_option_handler (graph, vme, "brick");
+
return ret;
}
@@ -2536,7 +2580,9 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
char *tmp = NULL;
gf_boolean_t var = _gf_false;
gf_boolean_t ob = _gf_false;
+ xlator_t *this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (conf);
volname = volinfo->volname;
@@ -2613,7 +2659,7 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
ob = _gf_false;
ret = gf_string2boolean (tmp, &ob);
if (!ret && ob) {
- gf_log (THIS->name, GF_LOG_WARNING,
+ gf_log (this->name, GF_LOG_WARNING,
"root-squash is enabled. Please turn it"
" off to change read-after-open "
"option");
@@ -2682,7 +2728,7 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
ret = 0;
}
if (ret) {
- gf_log (THIS->name, GF_LOG_WARNING, "setting "
+ gf_log (this->name, GF_LOG_WARNING, "setting "
"open behind option as part of root "
"squash failed");
goto out;
@@ -2708,14 +2754,28 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
&loglevel_option_handler);
if (ret)
- gf_log (THIS->name, GF_LOG_WARNING, "changing client log level"
+ gf_log (this->name, GF_LOG_WARNING, "changing client log level"
" failed");
ret = volgen_graph_set_options_generic (graph, set_dict, "client",
&sys_loglevel_option_handler);
if (ret)
- gf_log (THIS->name, GF_LOG_WARNING, "changing client syslog "
+ gf_log (this->name, GF_LOG_WARNING, "changing client syslog "
"level failed");
+
+ ret = volgen_graph_set_options_generic (graph, set_dict, "client",
+ &logger_option_handler);
+
+ if (ret)
+ gf_log (this->name, GF_LOG_WARNING, "changing client logger"
+ " failed");
+
+ ret = volgen_graph_set_options_generic (graph, set_dict, "client",
+ &log_format_option_handler);
+ if (ret)
+ gf_log (this->name, GF_LOG_WARNING, "changing client log format"
+ " failed");
+
out:
return ret;
}
@@ -3052,16 +3112,31 @@ build_shd_graph (volgen_graph_t *graph, dict_t *mod_dict)
&loglevel_option_handler);
if (ret)
- gf_log (THIS->name, GF_LOG_WARNING, "changing loglevel "
+ gf_log (this->name, GF_LOG_WARNING, "changing loglevel "
"of self-heal daemon failed");
ret = volgen_graph_set_options_generic (graph, set_dict,
"client",
&sys_loglevel_option_handler);
if (ret)
- gf_log (THIS->name, GF_LOG_WARNING, "changing syslog "
+ gf_log (this->name, GF_LOG_WARNING, "changing syslog "
"level of self-heal daemon failed");
+ ret = volgen_graph_set_options_generic (graph, set_dict,
+ "client",
+ &logger_option_handler);
+
+ if (ret)
+ gf_log (this->name, GF_LOG_WARNING, "changing logger "
+ "of self-heal daemon failed");
+
+ ret = volgen_graph_set_options_generic (graph, set_dict,
+ "client",
+ &log_format_option_handler);
+ if (ret)
+ gf_log (this->name, GF_LOG_WARNING, "changing log "
+ "format level of self-heal daemon failed");
+
ret = dict_reset (set_dict);
if (ret)
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index 7f094c439..29e9f2b87 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -610,6 +610,28 @@ struct volopt_map_entry glusterd_volopt_map[] = {
.op_version = 1,
.flags = OPT_FLAG_CLIENT_OPT
},
+ { .key = "diagnostics.brick-logger",
+ .voltype = "debug/io-stats",
+ .option = "!logger",
+ .op_version = 4
+ },
+ { .key = "diagnostics.client-logger",
+ .voltype = "debug/io-stats",
+ .option = "!logger",
+ .op_version = 4,
+ .flags = OPT_FLAG_CLIENT_OPT
+ },
+ { .key = "diagnostics.brick-log-format",
+ .voltype = "debug/io-stats",
+ .option = "!log-format",
+ .op_version = 4
+ },
+ { .key = "diagnostics.client-log-format",
+ .voltype = "debug/io-stats",
+ .option = "!log-format",
+ .op_version = 4,
+ .flags = OPT_FLAG_CLIENT_OPT
+ },
/* IO-cache xlator options */
{ .key = "performance.cache-max-file-size",