From dc3e568cfa5a37e531a18f2b3628b28fbcb41f1a Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Thu, 25 Feb 2010 15:37:55 +0000 Subject: trace: Support new option: force-log-level trace has till now forced the log level to be set to NORMAL. This masks other log output that we might need to observed in combination with the trace output. This new option allows us to force the log-level to something other than NORMAL. Signed-off-by: Shehjar Tikoo Signed-off-by: Anand V. Avati BUG: 168 (trace does not output debug messages) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=168 --- xlators/debug/trace/src/trace.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'xlators/debug') diff --git a/xlators/debug/trace/src/trace.c b/xlators/debug/trace/src/trace.c index fb86fc680..e559bf8b5 100644 --- a/xlators/debug/trace/src/trace.c +++ b/xlators/debug/trace/src/trace.c @@ -57,6 +57,7 @@ struct { int enabled; } trace_fop_names[GF_FOP_MAXVALUE]; +int trace_log_level = GF_LOG_NORMAL; static char * trace_stat_to_str (struct stat *stbuf) @@ -2048,6 +2049,7 @@ init (xlator_t *this) { dict_t *options = NULL; char *includes = NULL, *excludes = NULL; + char *forced_loglevel = NULL; if (!this) return -1; @@ -2087,8 +2089,30 @@ init (xlator_t *this) if (excludes) process_call_list (excludes, 0); - if (gf_log_get_loglevel () < GF_LOG_NORMAL) - gf_log_set_loglevel (GF_LOG_NORMAL); + if (dict_get (options, "force-log-level")) { + forced_loglevel = data_to_str (dict_get (options, + "force-log-level")); + if (!forced_loglevel) + goto setloglevel; + + if (strcmp (forced_loglevel, "NORMAL") == 0) + trace_log_level = GF_LOG_NORMAL; + else if (strcmp (forced_loglevel, "TRACE") == 0) + trace_log_level = GF_LOG_TRACE; + else if (strcmp (forced_loglevel, "ERROR") == 0) + trace_log_level = GF_LOG_ERROR; + else if (strcmp (forced_loglevel, "DEBUG") == 0) + trace_log_level = GF_LOG_DEBUG; + else if (strcmp (forced_loglevel, "WARNING") == 0) + trace_log_level = GF_LOG_WARNING; + else if (strcmp (forced_loglevel, "CRITICAL") == 0) + trace_log_level = GF_LOG_CRITICAL; + else if (strcmp (forced_loglevel, "NONE") == 0) + trace_log_level = GF_LOG_NONE; + } + +setloglevel: + gf_log_set_loglevel (trace_log_level); return 0; } -- cgit