diff options
Diffstat (limited to 'libglusterfs')
| -rw-r--r-- | libglusterfs/src/xlator.c | 90 | ||||
| -rw-r--r-- | libglusterfs/src/xlator.h | 1 | 
2 files changed, 91 insertions, 0 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 66508966a54..64f8b711017 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -1166,3 +1166,93 @@ xlator_destroy (xlator_t *xl)          return 0;  } +int +is_gf_log_command (xlator_t *this, const char *name, char *value) +{ +        xlator_t       *trav        = NULL; +        char            key[1024]   = {0,}; +        int             ret         = -1; +        int             log_level   = -1; +        gf_boolean_t    syslog_flag = 0; +        glusterfs_ctx_t *ctx        = NULL; + +        if (!strcmp ("trusted.glusterfs.syslog", name)) { +                ret = gf_string2boolean (value, &syslog_flag); +                if (ret) { +                        ret = EOPNOTSUPP; +                        goto out; +                } +                if (syslog_flag) +                        gf_log_enable_syslog (); +                else +                        gf_log_disable_syslog (); + +                goto out; +        } + +        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; +        } + +        if (log_level == -1) { +                ret = EOPNOTSUPP; +                goto out; +        } + +        /* Some crude way to change the log-level of process */ +        if (!strcmp (name, "trusted.glusterfs.set-log-level")) { +                /* */ +                gf_log ("glusterfs", gf_log_get_loglevel(), +                        "setting log level to %d (old-value=%d)", +                        log_level, gf_log_get_loglevel()); +                gf_log_set_loglevel (log_level); +                ret = 0; +                goto out; +        } +        if (!strcmp (name, "trusted.glusterfs.fuse.set-log-level")) { +                /* */ +                gf_log (this->name, gf_log_get_xl_loglevel (this), +                        "setting log level to %d (old-value=%d)", +                        log_level, gf_log_get_xl_loglevel (this)); +                gf_log_set_xl_loglevel (this, log_level); +                ret = 0; +                goto out; +        } + +        ctx = glusterfs_ctx_get(); +        if (!ctx) +                goto out; +        if (!ctx->active) +                goto out; +        trav = ctx->active->top; + +        while (trav) { +                snprintf (key, 1024, "trusted.glusterfs.%s.set-log-level", +                          trav->name); +                if (fnmatch (name, key, FNM_NOESCAPE) == 0) { +                        gf_log (trav->name, gf_log_get_xl_loglevel (trav), +                                "setting log level to %d (old-value=%d)", +                                log_level, gf_log_get_xl_loglevel (trav)); +                        gf_log_set_xl_loglevel (trav, log_level); +                        ret = 0; +                } +                trav = trav->next; +        } +out: +        return ret; +} diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index db5e652890c..d1cb839485a 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -859,6 +859,7 @@ int loc_copy (loc_t *dst, loc_t *src);  void loc_wipe (loc_t *loc);  int xlator_mem_acct_init (xlator_t *xl, int num_types);  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);  #define GF_STAT_PRINT_FMT_STR "%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx64",%"PRIx64",%"PRIx32",%"PRIx64",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32"\n"  | 
