From 4f942edde6aab3dbb825095bad76a58d5db8fe1f Mon Sep 17 00:00:00 2001
From: William Brown <wililam@adelaide.edu.au>
Date: Wed, 5 Aug 2015 07:02:12 +0930
Subject: [PATCH] Rename level to service in all log related functions and
 tests

---
 lib389/__init__.py          |  4 ++--
 lib389/brooker.py           | 44 ++++++++++++++++++++++----------------------
 tests/config_test.py        |  4 ++--
 tests/dsadmin_basic_test.py |  2 +-
 tests/dsadmin_test.py       |  2 +-
 5 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/lib389/__init__.py b/lib389/__init__.py
index 42df566..0557a83 100644
--- a/lib389/__init__.py
+++ b/lib389/__init__.py
@@ -1969,7 +1969,7 @@ class DirSrv(SimpleLDAPObject):
 
     def setAccessLogLevel(self, *vals):
         """Set nsslapd-accesslog-level and return its value."""
-        return self.config.loglevel(vals, level='access')
+        return self.config.loglevel(vals, service='access')
 
     def configSSL(self, secport=636, secargs=None):
         """Configure SSL support into cn=encryption,cn=config.
@@ -2266,4 +2266,4 @@ class DirSrv(SimpleLDAPObject):
         return DirSrvTools.searchFile(self.errlog, pattern)
 
     def detectDisorderlyShutdown(self):
-        return DirSrvTools.searchFile(self.errlog, DISORDERLY_SHUTDOWN)
\ No newline at end of file
+        return DirSrvTools.searchFile(self.errlog, DISORDERLY_SHUTDOWN)
diff --git a/lib389/brooker.py b/lib389/brooker.py
index 6dadfcb..f7a5fc8 100644
--- a/lib389/brooker.py
+++ b/lib389/brooker.py
@@ -53,54 +53,54 @@ class Config(object):
         """Get an attribute under cn=config"""
         return self.conn.getEntry(DN_CONFIG).__getattr__(key)
 
-    def _alter_log_enabled(self, level, state):
-        if level not in ('access', 'error', 'audit'):
-            self.log.error('Attempted to enable invalid log service "%s"' % level)
-        level = 'nsslapd-%slog-logging-enabled' % level
-        self.log.debug('Setting log %s to %s' % (level, state))
-        self.set(level, state)
-
-    def enable_log(self, level):
+    def _alter_log_enabled(self, service, state):
+        if service not in ('access', 'error', 'audit'):
+            self.log.error('Attempted to enable invalid log service "%s"' % service)
+        service = 'nsslapd-%slog-logging-enabled' % service
+        self.log.debug('Setting log %s to %s' % (service, state))
+        self.set(service, state)
+
+    def enable_log(self, service):
         """Enable a logging service in the 389ds instance.
-        @param level - The logging service to enable. Can be one of 'access', 'error' or 'audit'.
+        @param service - The logging service to enable. Can be one of 'access', 'error' or 'audit'.
 
         ex. enable_log('audit')
         """
-        self._alter_log_enabled(level, 'on')
+        self._alter_log_enabled(service, 'on')
 
-    def disable_log(self, level):
+    def disable_log(self, service):
         """Disable a logging service in the 389ds instance.
-        @param level - The logging service to Disable. Can be one of 'access', 'error' or 'audit'.
+        @param service - The logging service to Disable. Can be one of 'access', 'error' or 'audit'.
 
         ex. disable_log('audit')
         """
-        self._alter_log_enabled(level, 'off')
+        self._alter_log_enabled(service, 'off')
 
-    def loglevel(self, vals=(LOG_DEFAULT,), level='error', update=False):
+    def loglevel(self, vals=(LOG_DEFAULT,), service='error', update=False):
         """Set the access or error log level.
         @param vals - a list of log level codes (eg. lib389.LOG_*) 
                       defaults to LOG_DEFAULT
-        @param level   -   'access' or 'error'. There is no 'audit' log level. use enable_log or disable_log.
+        @param service -   'access' or 'error'. There is no 'audit' log level. use enable_log or disable_log.
         @param update  - False for replace (default), True for update
 
         ex. loglevel([lib389.LOG_DEFAULT, lib389.LOG_ENTRY_PARSER])
         """
-        if level not in ('access', 'error'):
-            self.log.error('Attempted to set level on invalid log service "%s"' % level)
-        level = 'nsslapd-%slog-level' % level
+        if service not in ('access', 'error'):
+            self.log.error('Attempted to set level on invalid log service "%s"' % service)
+        service = 'nsslapd-%slog-level' % service
         assert len(vals) > 0, "set at least one log level"
         tot = 0
         for v in vals:
             tot |= v
 
         if update:
-            old = int(self.get(level))
+            old = int(self.get(service))
             tot |= old
-            self.log.debug("Update %s value: %r -> %r" % (level, old, tot))
+            self.log.debug("Update %s value: %r -> %r" % (service, old, tot))
         else:
-            self.log.debug("Replace %s with value: %r" % (level, tot))
+            self.log.debug("Replace %s with value: %r" % (service, tot))
 
-        self.set(level, str(tot))
+        self.set(service, str(tot))
         return tot
 
     def enable_ssl(self, secport=636, secargs=None):
diff --git a/tests/config_test.py b/tests/config_test.py
index e4eaefd..bcec4b3 100644
--- a/tests/config_test.py
+++ b/tests/config_test.py
@@ -51,7 +51,7 @@ def setup():
 def teardown():
     global conn
     conn.config.loglevel([lib389.LOG_CACHE])
-    conn.config.loglevel([256], level='access')
+    conn.config.loglevel([256], service='access')
     
     """
     drop_added_entries(conn)
@@ -79,5 +79,5 @@ def loglevel_update_test():
 
 def access_loglevel_test():
     vals = [lib389.LOG_CACHE, lib389.LOG_REPLICA, lib389.LOG_CONNECT]
-    assert conn.config.loglevel(vals, level='access') == sum(vals)
+    assert conn.config.loglevel(vals, service='access') == sum(vals)
 
diff --git a/tests/dsadmin_basic_test.py b/tests/dsadmin_basic_test.py
index 422c1c2..5d57dfb 100644
--- a/tests/dsadmin_basic_test.py
+++ b/tests/dsadmin_basic_test.py
@@ -34,7 +34,7 @@ def tearDown():
 
     # reduce log level
     conn.config.loglevel([lib389.LOG_CACHE])
-    conn.config.loglevel([256], level='access')
+    conn.config.loglevel([256], service='access')
 
     for e in conn.added_entries:
         try:
diff --git a/tests/dsadmin_test.py b/tests/dsadmin_test.py
index 251617d..8f28d03 100644
--- a/tests/dsadmin_test.py
+++ b/tests/dsadmin_test.py
@@ -22,7 +22,7 @@ added_backends = None
 
 def harn_nolog():
     conn.config.loglevel([lib389.LOG_DEFAULT])
-    conn.config.loglevel([lib389.LOG_DEFAULT], level='access')
+    conn.config.loglevel([lib389.LOG_DEFAULT], service='access')
 
 
 def setup():
-- 
2.4.3

