summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2016-08-02 16:17:36 +0530
committerJeff Darcy <jdarcy@redhat.com>2016-08-15 05:04:15 -0700
commit206fd324e33127d4c370007f223f8c12ab06b714 (patch)
tree69b1b568860ac826bcb0e391a0acc554c99a252c /libglusterfs
parent79b9ad3dfa146ef29ac99bf87d1c31f5a6fe1fef (diff)
logging: Fix per xl log level
Currently per xlator loglevel setting doesn't work, due to the flaw in loglevel checking. Fix the same. Per xlator logging can be set using the below command: Eg: setfattr -n trusted.glusterfs.patchy-md-cache.set-log-level -v TRACE /mnt/glusterfs/0 Change-Id: I8ff1d15bd5693b6f682d99bee22a4bbb5eee646c BUG: 1362520 Signed-off-by: Poornima G <pgurusid@redhat.com> Reviewed-on: http://review.gluster.org/15071 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/logging.c73
-rw-r--r--libglusterfs/src/logging.h1
2 files changed, 32 insertions, 42 deletions
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index 4408c5f674c..55cf2e97d2c 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -164,7 +164,6 @@ gf_log_set_xl_loglevel (void *this, gf_loglevel_t level)
xlator_t *xl = this;
if (!xl)
return;
- xl->ctx->log.gf_log_xl_log_set = 1;
xl->loglevel = level;
}
@@ -770,6 +769,30 @@ set_sys_log_level (gf_loglevel_t level)
ctx->log.sys_log_level = level;
}
+/* Check if we should be logging
+ * Return value: _gf_false : Print the log
+ * _gf_true : Do not Print the log
+ */
+static gf_boolean_t
+skip_logging (xlator_t *this, gf_loglevel_t level)
+{
+ gf_boolean_t ret = _gf_false;
+ gf_loglevel_t existing_level = GF_LOG_NONE;
+
+ if (level == GF_LOG_NONE) {
+ ret = _gf_true;
+ goto out;
+ }
+
+ existing_level = this->loglevel ? this->loglevel : this->ctx->log.loglevel;
+ if (level > existing_level) {
+ ret = _gf_true;
+ goto out;
+ }
+out:
+ return ret;
+}
+
int
_gf_log_callingfn (const char *domain, const char *file, const char *function,
int line, gf_loglevel_t level, const char *fmt, ...)
@@ -793,11 +816,7 @@ _gf_log_callingfn (const char *domain, const char *file, const char *function,
if (!ctx)
goto out;
- if (ctx->log.gf_log_xl_log_set) {
- if (this->loglevel && (level > this->loglevel))
- goto out;
- }
- if (level > ctx->log.loglevel || level == GF_LOG_NONE)
+ if (skip_logging (this, level))
goto out;
static char *level_strings[] = {"", /* NONE */
@@ -984,11 +1003,7 @@ _gf_msg_plain (gf_loglevel_t level, const char *fmt, ...)
if (!ctx)
goto out;
- if (ctx->log.gf_log_xl_log_set) {
- if (this->loglevel && (level > this->loglevel))
- goto out;
- }
- if (level > ctx->log.loglevel || level == GF_LOG_NONE)
+ if (skip_logging (this, level))
goto out;
va_start (ap, fmt);
@@ -1020,11 +1035,7 @@ _gf_msg_vplain (gf_loglevel_t level, const char *fmt, va_list ap)
if (!ctx)
goto out;
- if (ctx->log.gf_log_xl_log_set) {
- if (this->loglevel && (level > this->loglevel))
- goto out;
- }
- if (level > ctx->log.loglevel || level == GF_LOG_NONE)
+ if (skip_logging (this, level))
goto out;
ret = vasprintf (&msg, fmt, ap);
@@ -1052,11 +1063,7 @@ _gf_msg_plain_nomem (gf_loglevel_t level, const char *msg)
if (!ctx)
goto out;
- if (ctx->log.gf_log_xl_log_set) {
- if (this->loglevel && (level > this->loglevel))
- goto out;
- }
- if (level > ctx->log.loglevel || level == GF_LOG_NONE)
+ if (skip_logging (this, level))
goto out;
ret = _gf_msg_plain_internal (level, msg);
@@ -1084,11 +1091,7 @@ _gf_msg_backtrace_nomem (gf_loglevel_t level, int stacksize)
if (ctx->log.logger != gf_logger_glusterlog)
goto out;
- if (ctx->log.gf_log_xl_log_set) {
- if (this->loglevel && (level > this->loglevel))
- goto out;
- }
- if (level > ctx->log.loglevel || level == GF_LOG_NONE)
+ if (skip_logging (this, level))
goto out;
bt_size = backtrace (array, ((stacksize <= 200)? stacksize : 200));
@@ -1171,11 +1174,7 @@ _gf_msg_nomem (const char *domain, const char *file,
if (!ctx)
goto out;
- if (ctx->log.gf_log_xl_log_set) {
- if (this->loglevel && (level > this->loglevel))
- goto out;
- }
- if (level > ctx->log.loglevel || level == GF_LOG_NONE)
+ if (skip_logging (this, level))
goto out;
if (!domain || !file || !function) {
@@ -2040,11 +2039,7 @@ _gf_msg (const char *domain, const char *file, const char *function,
}
/* check if we should be logging */
- if (ctx->log.gf_log_xl_log_set) {
- if (this->loglevel && (level > this->loglevel))
- goto out;
- }
- if (level > ctx->log.loglevel || level == GF_LOG_NONE)
+ if (skip_logging (this, level))
goto out;
if (trace) {
@@ -2121,11 +2116,7 @@ _gf_log (const char *domain, const char *file, const char *function, int line,
if (!ctx)
goto out;
- if (ctx->log.gf_log_xl_log_set) {
- if (this->loglevel && (level > this->loglevel))
- goto out;
- }
- if (level > ctx->log.loglevel || level == GF_LOG_NONE)
+ if (skip_logging (this, level))
goto out;
static char *level_strings[] = {"", /* NONE */
diff --git a/libglusterfs/src/logging.h b/libglusterfs/src/logging.h
index f3a694ceefd..a6e318dc3fa 100644
--- a/libglusterfs/src/logging.h
+++ b/libglusterfs/src/logging.h
@@ -100,7 +100,6 @@ typedef struct gf_log_handle_ {
gf_loglevel_t loglevel;
int gf_log_syslog;
gf_loglevel_t sys_log_level;
- char gf_log_xl_log_set;
char *filename;
FILE *logfile;
FILE *gf_log_logfile;