aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStevan Radaković <stevan.radakovic@linaro.org>2013-03-04 16:32:26 +0800
committerStevan Radaković <stevan.radakovic@linaro.org>2013-03-04 16:32:26 +0800
commit4e4997415693ad2273a714ff1a87b5e8dff509b5 (patch)
treed0b4ccde8a24372af4b631917989e9010f4278f8
parent01174e45feff1023b1d299655dc547ddfc9cbfc2 (diff)
downloadrhodecode-config-4e4997415693ad2273a714ff1a87b5e8dff509b5.tar.gz
Add logging settings to .conf file and add logging handler.
-rw-r--r--scripts/ldap_sync.conf26
-rw-r--r--scripts/ldap_sync.py17
2 files changed, 36 insertions, 7 deletions
diff --git a/scripts/ldap_sync.conf b/scripts/ldap_sync.conf
index 8e54019..46ea509 100644
--- a/scripts/ldap_sync.conf
+++ b/scripts/ldap_sync.conf
@@ -1,4 +1,4 @@
-[default]
+[ldap_config]
api_url = http://your.rhodecode.server:5000/_admin/api
api_user = admin
api_key = XXXXXXXXXXXX
@@ -9,3 +9,27 @@ ldap_key = XXXXXXXXX
base_dn = dc=linaro,dc=org
sync_users = True
+
+[loggers]
+keys=root
+
+[logger_root]
+level=DEBUG
+handlers=file
+
+[formatters]
+keys=simple
+
+[formatter_simple]
+format=%(asctime)s %(levelname)-8s %(message)s
+
+[handlers]
+keys=file
+
+[handler_file]
+class=handlers.TimedRotatingFileHandler
+interval=midnight
+backupCount=10
+formatter=simple
+level=DEBUG
+args=('/tmp/test.log',)
diff --git a/scripts/ldap_sync.py b/scripts/ldap_sync.py
index 71c1479..32309b7 100644
--- a/scripts/ldap_sync.py
+++ b/scripts/ldap_sync.py
@@ -12,6 +12,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import ldap
+import logging
+import logging.config
import urllib2
import uuid
import json
@@ -21,6 +23,9 @@ from ConfigParser import ConfigParser
config = ConfigParser()
config.read('ldap_sync.conf')
+logging.config.fileConfig('ldap_sync.conf')
+logger = logging.getLogger()
+
class InvalidResponseIDError(Exception):
''' Request and response don't have the same UUID. '''
@@ -175,12 +180,12 @@ class LdapClient():
class LdapSync():
def __init__(self):
- self.ldap_client = LdapClient(config.get("default", "ldap_uri"),
- config.get("default", "ldap_user"),
- config.get("default", "ldap_key"),
- config.get("default", "base_dn"))
- self.rhodecode_api = RhodecodeAPI(config.get("default", "api_url"),
- config.get("default", "api_key"))
+ self.ldap_client = LdapClient(config.get("ldap_config", "ldap_uri"),
+ config.get("ldap_config", "ldap_user"),
+ config.get("ldap_config", "ldap_key"),
+ config.get("ldap_config", "base_dn"))
+ self.rhodecode_api = RhodecodeAPI(config.get("ldap_config", "api_url"),
+ config.get("ldap_config", "api_key"))
def update_groups_from_ldap(self):
"""Add all the groups from LDAP to Rhodecode."""