diff options
Diffstat (limited to 'libglusterfs/src')
| -rw-r--r-- | libglusterfs/src/xlator.c | 45 | ||||
| -rw-r--r-- | libglusterfs/src/xlator.h | 1 | 
2 files changed, 30 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; +} diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index 5d90a6e7813..e583e8c1308 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -864,6 +864,7 @@ int xlator_tree_reconfigure (xlator_t *old_xl, xlator_t *new_xl);  int is_gf_log_command (xlator_t *trans, const char *name, char *value);  int xlator_validate_rec (xlator_t *xlator, char **op_errstr);  int graph_reconf_validateopt (glusterfs_graph_t *graph, char **op_errstr); +int glusterd_check_log_level (const char *value);  #define GF_STAT_PRINT_FMT_STR "%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32"\n"  | 
