3604df
From 17976f33033f81429754f14c10b8078f7a24ed8b Mon Sep 17 00:00:00 2001
3604df
From: Aravinda VK <avishwan@redhat.com>
3604df
Date: Wed, 3 Aug 2016 17:52:20 +0530
3604df
Subject: [PATCH 71/86] geo-rep: Use configured log_level for libgfchangelog logs
3604df
3604df
libgfchangelog was not respecting the log_level configured
3604df
in Geo-replication. With this patch Libgfchangelog log level
3604df
can be configured using `config changelog_log_level TRACE`.
3604df
Default Changelog log level is INFO
3604df
3604df
> Reviewed-on: http://review.gluster.org/15078
3604df
> Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
> Reviewed-by: Kotresh HR <khiremat@redhat.com>
3604df
3604df
BUG: 1363729
3604df
Change-Id: Ida714931129f6a1331b9d0815da77efcb2b898e3
3604df
Signed-off-by: Aravinda VK <avishwan@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/84837
3604df
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
---
3604df
 geo-replication/syncdaemon/gsyncd.py     |    1 +
3604df
 geo-replication/syncdaemon/master.py     |    1 -
3604df
 geo-replication/syncdaemon/resource.py   |    4 +++-
3604df
 geo-replication/syncdaemon/syncdutils.py |   17 +++++++++++++++++
3604df
 4 files changed, 21 insertions(+), 2 deletions(-)
3604df
3604df
diff --git a/geo-replication/syncdaemon/gsyncd.py b/geo-replication/syncdaemon/gsyncd.py
3604df
index c2699a1..b459abc 100644
3604df
--- a/geo-replication/syncdaemon/gsyncd.py
3604df
+++ b/geo-replication/syncdaemon/gsyncd.py
3604df
@@ -244,6 +244,7 @@ def main_i():
3604df
                   default=os.devnull, type=str, action='callback',
3604df
                   callback=store_abs)
3604df
     op.add_option('--gluster-log-level', metavar='LVL')
3604df
+    op.add_option('--changelog-log-level', metavar='LVL', default="INFO")
3604df
     op.add_option('--gluster-params', metavar='PRMS', default='')
3604df
     op.add_option(
3604df
         '--glusterd-uuid', metavar='UUID', type=str, default='',
3604df
diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py
3604df
index 80c4d9d..796b980 100644
3604df
--- a/geo-replication/syncdaemon/master.py
3604df
+++ b/geo-replication/syncdaemon/master.py
3604df
@@ -673,7 +673,6 @@ class GMasterChangelogMixin(GMasterCommon):
3604df
     # maximum retries per changelog before giving up
3604df
     MAX_RETRIES = 10
3604df
 
3604df
-    CHANGELOG_LOG_LEVEL = 9
3604df
     CHANGELOG_CONN_RETRIES = 5
3604df
 
3604df
     def archive_and_purge_changelogs(self, changelogs):
3604df
diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py
3604df
index ed0e7ef..70d420e 100644
3604df
--- a/geo-replication/syncdaemon/resource.py
3604df
+++ b/geo-replication/syncdaemon/resource.py
3604df
@@ -37,6 +37,7 @@ from syncdutils import GsyncdError, select, privileged, boolify, funcode
3604df
 from syncdutils import umask, entry2pb, gauxpfx, errno_wrap, lstat
3604df
 from syncdutils import NoPurgeTimeAvailable, PartialHistoryAvailable
3604df
 from syncdutils import ChangelogException, ChangelogHistoryNotAvailable
3604df
+from syncdutils import get_changelog_log_level
3604df
 from syncdutils import CHANGELOG_AGENT_CLIENT_VERSION
3604df
 from gsyncdstatus import GeorepStatus
3604df
 
3604df
@@ -1481,7 +1482,8 @@ class GLUSTER(AbstractUrl, SlaveLocal, SlaveRemote):
3604df
                     changelog_agent.init()
3604df
                     changelog_agent.register(gconf.local_path,
3604df
                                              workdir, gconf.changelog_log_file,
3604df
-                                             g2.CHANGELOG_LOG_LEVEL,
3604df
+                                             get_changelog_log_level(
3604df
+                                                 gconf.changelog_log_level),
3604df
                                              g2.CHANGELOG_CONN_RETRIES)
3604df
 
3604df
                 register_time = int(time.time())
3604df
diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py
3604df
index 40eff05..987e1bf 100644
3604df
--- a/geo-replication/syncdaemon/syncdutils.py
3604df
+++ b/geo-replication/syncdaemon/syncdutils.py
3604df
@@ -506,3 +506,20 @@ class ChangelogHistoryNotAvailable(Exception):
3604df
 
3604df
 class ChangelogException(OSError):
3604df
     pass
3604df
+
3604df
+
3604df
+class GlusterLogLevel(object):
3604df
+        NONE = 0
3604df
+        EMERG = 1
3604df
+        ALERT = 2
3604df
+        CRITICAL = 3
3604df
+        ERROR = 4
3604df
+        WARNING = 5
3604df
+        NOTICE = 6
3604df
+        INFO = 7
3604df
+        DEBUG = 8
3604df
+        TRACE = 9
3604df
+
3604df
+
3604df
+def get_changelog_log_level(lvl):
3604df
+    return getattr(GlusterLogLevel, lvl, GlusterLogLevel.INFO)
3604df
-- 
3604df
1.7.1
3604df