Blob Blame History Raw
From 17976f33033f81429754f14c10b8078f7a24ed8b Mon Sep 17 00:00:00 2001
From: Aravinda VK <avishwan@redhat.com>
Date: Wed, 3 Aug 2016 17:52:20 +0530
Subject: [PATCH 71/86] geo-rep: Use configured log_level for libgfchangelog logs

libgfchangelog was not respecting the log_level configured
in Geo-replication. With this patch Libgfchangelog log level
can be configured using `config changelog_log_level TRACE`.
Default Changelog log level is INFO

> Reviewed-on: http://review.gluster.org/15078
> 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: Kotresh HR <khiremat@redhat.com>

BUG: 1363729
Change-Id: Ida714931129f6a1331b9d0815da77efcb2b898e3
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/84837
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 geo-replication/syncdaemon/gsyncd.py     |    1 +
 geo-replication/syncdaemon/master.py     |    1 -
 geo-replication/syncdaemon/resource.py   |    4 +++-
 geo-replication/syncdaemon/syncdutils.py |   17 +++++++++++++++++
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/geo-replication/syncdaemon/gsyncd.py b/geo-replication/syncdaemon/gsyncd.py
index c2699a1..b459abc 100644
--- a/geo-replication/syncdaemon/gsyncd.py
+++ b/geo-replication/syncdaemon/gsyncd.py
@@ -244,6 +244,7 @@ def main_i():
                   default=os.devnull, type=str, action='callback',
                   callback=store_abs)
     op.add_option('--gluster-log-level', metavar='LVL')
+    op.add_option('--changelog-log-level', metavar='LVL', default="INFO")
     op.add_option('--gluster-params', metavar='PRMS', default='')
     op.add_option(
         '--glusterd-uuid', metavar='UUID', type=str, default='',
diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py
index 80c4d9d..796b980 100644
--- a/geo-replication/syncdaemon/master.py
+++ b/geo-replication/syncdaemon/master.py
@@ -673,7 +673,6 @@ class GMasterChangelogMixin(GMasterCommon):
     # maximum retries per changelog before giving up
     MAX_RETRIES = 10
 
-    CHANGELOG_LOG_LEVEL = 9
     CHANGELOG_CONN_RETRIES = 5
 
     def archive_and_purge_changelogs(self, changelogs):
diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py
index ed0e7ef..70d420e 100644
--- a/geo-replication/syncdaemon/resource.py
+++ b/geo-replication/syncdaemon/resource.py
@@ -37,6 +37,7 @@ from syncdutils import GsyncdError, select, privileged, boolify, funcode
 from syncdutils import umask, entry2pb, gauxpfx, errno_wrap, lstat
 from syncdutils import NoPurgeTimeAvailable, PartialHistoryAvailable
 from syncdutils import ChangelogException, ChangelogHistoryNotAvailable
+from syncdutils import get_changelog_log_level
 from syncdutils import CHANGELOG_AGENT_CLIENT_VERSION
 from gsyncdstatus import GeorepStatus
 
@@ -1481,7 +1482,8 @@ class GLUSTER(AbstractUrl, SlaveLocal, SlaveRemote):
                     changelog_agent.init()
                     changelog_agent.register(gconf.local_path,
                                              workdir, gconf.changelog_log_file,
-                                             g2.CHANGELOG_LOG_LEVEL,
+                                             get_changelog_log_level(
+                                                 gconf.changelog_log_level),
                                              g2.CHANGELOG_CONN_RETRIES)
 
                 register_time = int(time.time())
diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py
index 40eff05..987e1bf 100644
--- a/geo-replication/syncdaemon/syncdutils.py
+++ b/geo-replication/syncdaemon/syncdutils.py
@@ -506,3 +506,20 @@ class ChangelogHistoryNotAvailable(Exception):
 
 class ChangelogException(OSError):
     pass
+
+
+class GlusterLogLevel(object):
+        NONE = 0
+        EMERG = 1
+        ALERT = 2
+        CRITICAL = 3
+        ERROR = 4
+        WARNING = 5
+        NOTICE = 6
+        INFO = 7
+        DEBUG = 8
+        TRACE = 9
+
+
+def get_changelog_log_level(lvl):
+    return getattr(GlusterLogLevel, lvl, GlusterLogLevel.INFO)
-- 
1.7.1