[SEBA-219]

Change synchronizer framework to log only at TRACE level (sub-DEBUG)

Change-Id: Id29cbc87339d74ececd0a8fc29832e879f6f13f6
diff --git a/lib/xos-config/xosconfig/__init__.py b/lib/xos-config/xosconfig/__init__.py
index 105d4a0..a557ff4 100644
--- a/lib/xos-config/xosconfig/__init__.py
+++ b/lib/xos-config/xosconfig/__init__.py
@@ -1,4 +1,3 @@
-
 # Copyright 2017-present Open Networking Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,5 +12,23 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 from .config import Config
+
+# Custom TRACE logging level
+# ref: https://stackoverflow.com/questions/2183233/how-to-add-a-custom-loglevel-to-pythons-logging-facility/13638084#13638084
+
+import logging
+
+# Logging levels: https://docs.python.org/2/library/logging.html#logging-levels
+# Add a sub-DEBUG Trace level
+TRACE_LOGLVL = 5
+
+logging.addLevelName(TRACE_LOGLVL, "TRACE")
+
+
+def trace_loglevel(self, message, *args, **kws):
+    if self.isEnabledFor(TRACE_LOGLVL):
+        self._log(TRACE_LOGLVL, message, args, **kws)
+
+
+logging.Logger.trace = trace_loglevel
diff --git a/xos/synchronizers/new_base/event_loop.py b/xos/synchronizers/new_base/event_loop.py
index 4f44cc9..23fb2ab 100644
--- a/xos/synchronizers/new_base/event_loop.py
+++ b/xos/synchronizers/new_base/event_loop.py
@@ -100,10 +100,10 @@
 
         try:
             if Config.get("dependency_graph"):
-                self.log.info('Loading model dependency graph', path=Config.get("dependency_graph"))
+                self.log.trace('Loading model dependency graph', path=Config.get("dependency_graph"))
                 dep_graph_str = open(Config.get("dependency_graph")).read()
             else:
-                self.log.debug('Using defualt model dependency graph', graph={})
+                self.log.trace('Using defualt model dependency graph', graph={})
                 dep_graph_str = '{}'
 
             # joint_dependencies is of the form { Model1 -> [(Model2, src_port, dst_port), ...] }
@@ -132,7 +132,7 @@
                 True: model_dependency_graph_rev,
                 False: model_dependency_graph
             }
-            self.log.info(
+            self.log.trace(
                 "Loaded dependencies",
                 edges=model_dependency_graph.edges())
         except Exception as e:
@@ -442,9 +442,9 @@
             return
 
         while True:
-            self.log.debug('Waiting for event or timeout')
+            self.log.trace('Waiting for event or timeout')
             self.wait_for_event(timeout=5)
-            self.log.debug('Synchronizer awake')
+            self.log.trace('Synchronizer awake')
 
             self.run_once()
 
@@ -483,7 +483,7 @@
                 # This needs to be dropped soon.
                 pending_steps.append(step)
 
-        self.log.debug(
+        self.log.trace(
             'Fetched pending data',
             pending_objects=pending_objects,
             legacy_steps=pending_steps)
@@ -689,7 +689,7 @@
                     objects_to_process, deletion)
 
                 threads = []
-                self.log.debug('In run once inner loop', deletion=deletion)
+                self.log.trace('In run once inner loop', deletion=deletion)
 
                 for cohort in dependent_cohorts:
                     thread = threading.Thread(
diff --git a/xos/synchronizers/new_base/pull_step_engine.py b/xos/synchronizers/new_base/pull_step_engine.py
index 22ab643..0d989a1 100644
--- a/xos/synchronizers/new_base/pull_step_engine.py
+++ b/xos/synchronizers/new_base/pull_step_engine.py
@@ -23,6 +23,7 @@
 
 log = create_logger(Config().get('logging'))
 
+
 class XOSPullStepScheduler():
     """ XOSPullStepThread
 
@@ -39,7 +40,7 @@
             self.run_once()
 
     def run_once(self):
-        log.debug('Starting pull steps', steps=self.steps)
+        log.trace('Starting pull steps', steps=self.steps)
 
         threads = []
         for step in self.steps:
@@ -52,8 +53,7 @@
         for t in threads:
             t.join()
 
-        log.debug('Done with pull steps', steps=self.steps)
-
+        log.trace('Done with pull steps', steps=self.steps)
 
 
 class XOSPullStepEngine: