diff options
author | shishir gowda <shishirng@gluster.com> | 2010-10-18 08:15:30 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-10-24 22:43:00 -0700 |
commit | cfad660310978ffda6263d44ab2445d42c2621b2 (patch) | |
tree | df77387dcf6d67e8c9c7113e396ef2c450e7218f /libglusterfs/src/xlator.c | |
parent | f014877f37488d6f9d4c505f0675ad45cd770546 (diff) |
Log level mess clean up
Signed-off-by: shishir gowda <shishirng@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 1886 (log-level mess)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1886
Diffstat (limited to 'libglusterfs/src/xlator.c')
-rw-r--r-- | libglusterfs/src/xlator.c | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 7966b3dde85..fa1ad198da7 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -1260,22 +1260,7 @@ is_gf_log_command (xlator_t *this, const char *name, char *value) if (fnmatch ("trusted.glusterfs*set-log-level", name, FNM_NOESCAPE)) goto out; - if (!strcasecmp (value, "CRITICAL")) { - log_level = GF_LOG_CRITICAL; - } else if (!strcasecmp (value, "ERROR")) { - log_level = GF_LOG_ERROR; - } else if (!strcasecmp (value, "WARNING")) { - log_level = GF_LOG_WARNING; - } else if (!strcasecmp (value, "INFO")) { - log_level = GF_LOG_INFO; - } else if (!strcasecmp (value, "DEBUG")) { - log_level = GF_LOG_DEBUG; - } else if (!strcasecmp (value, "TRACE")) { - log_level = GF_LOG_TRACE; - } else if (!strcasecmp (value, "NONE")) { - log_level = GF_LOG_NONE; - } - + log_level = glusterd_check_log_level (value); if (log_level == -1) { ret = EOPNOTSUPP; goto out; @@ -1323,3 +1308,31 @@ is_gf_log_command (xlator_t *this, const char *name, char *value) out: return ret; } + +int +glusterd_check_log_level (const char *value) +{ + int log_level = -1; + + if (!strcasecmp (value, "CRITICAL")) { + log_level = GF_LOG_CRITICAL; + } else if (!strcasecmp (value, "ERROR")) { + log_level = GF_LOG_ERROR; + } else if (!strcasecmp (value, "WARNING")) { + log_level = GF_LOG_WARNING; + } else if (!strcasecmp (value, "INFO")) { + log_level = GF_LOG_INFO; + } else if (!strcasecmp (value, "DEBUG")) { + log_level = GF_LOG_DEBUG; + } else if (!strcasecmp (value, "TRACE")) { + log_level = GF_LOG_TRACE; + } else if (!strcasecmp (value, "NONE")) { + log_level = GF_LOG_NONE; + } + + if (log_level == -1) + gf_log ("", GF_LOG_ERROR, "Invalid log-level. possible values " + "are DEBUG|WARNING|ERROR|CRITICAL|NONE|TRACE"); + + return log_level; +} |