diff --git a/ldapcherry/__init__.py b/ldapcherry/__init__.py index 3c99ea2..5e9f320 100644 --- a/ldapcherry/__init__.py +++ b/ldapcherry/__init__.py @@ -197,6 +197,10 @@ class LdapCherry(object): # definition of the template directory self.template_dir = self._get_param('resources', 'templates.dir', config) + cherrypy.log.error( + msg = "Loading templates from dir <%(dir)s>" % { 'dir': self.template_dir }, + severity = logging.DEBUG + ) # preload templates self.temp_lookup = lookup.TemplateLookup( directories=self.template_dir, input_encoding='utf-8' @@ -210,16 +214,38 @@ class LdapCherry(object): #auth = __import__(auth_module, globals(), locals(), ['Auth'], -1) #self.auth = auth.Auth(config['auth'], cherrypy.log) + self.roles_file = self._get_param('roles', 'roles.file', config) + cherrypy.log.error( + msg = "Loading roles file <%(file)s>" % { 'file': self.roles_file }, + severity = logging.DEBUG + ) self.roles = Roles(self.roles_file) self.attributes_file = self._get_param('attributes', 'attributes.file', config) - self.roles = Attributes(self.attributes_file) + cherrypy.log.error( + msg = "Loading attributes file <%(file)s>" % { 'file': self.attributes_file }, + severity = logging.DEBUG + ) + self.attributes = Attributes(self.attributes_file) + + cherrypy.log.error( + msg = "Init directories backends", + severity = logging.DEBUG + ) self._init_backends(config) self._check_backends() + cherrypy.log.error( + msg = "Application started", + severity = logging.INFO + ) except Exception as e: self._handle_exception(e) + cherrypy.log.error( + msg = "Application failed to start", + severity = logging.ERROR + ) exit(1) def _reraise(self, exception): diff --git a/tests/test_LdapCherry.py b/tests/test_LdapCherry.py index a82c929..b0235ac 100644 --- a/tests/test_LdapCherry.py +++ b/tests/test_LdapCherry.py @@ -58,7 +58,7 @@ class TestError(object): cfg['global']['log.access_handler']=t cfg['global']['log.error_handler']=t app._set_access_log(cfg, logging.DEBUG) - app._set_access_log(cfg, logging.DEBUG) + app._set_error_log(cfg, logging.DEBUG) def testMissingBackend(self): app = LdapCherry() @@ -71,7 +71,6 @@ class TestError(object): else: raise AssertionError("expected an exception") - def testMissingParameters(self): app = LdapCherry() try: @@ -81,6 +80,12 @@ class TestError(object): else: raise AssertionError("expected an exception") + def testRandomException(self): + app = LdapCherry() + loadconf('./tests/cfg/ldapcherry.ini', app) + e = Exception() + app._handle_exception(e) + def testLogger(self): app = LdapCherry() loadconf('./tests/cfg/ldapcherry.ini', app)