mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-22 09:24:21 +01:00
implementing debug mode in console
This commit is contained in:
parent
5944b81aed
commit
8b0e68d9db
@ -260,7 +260,7 @@ class LdapCherry(object):
|
||||
# set log level
|
||||
cherrypy.log.access_log.setLevel(level)
|
||||
|
||||
def _set_error_log(self, config, level):
|
||||
def _set_error_log(self, config, level, debug=False):
|
||||
""" Configure error logs
|
||||
"""
|
||||
error_handler = self._get_param(
|
||||
@ -305,6 +305,12 @@ class LdapCherry(object):
|
||||
# set log level
|
||||
cherrypy.log.error_log.setLevel(level)
|
||||
|
||||
if debug:
|
||||
handler = logging.StreamHandler(sys.stderr)
|
||||
handler.setLevel(logging.DEBUG)
|
||||
cherrypy.log.error_log.addHandler(handler)
|
||||
cherrypy.log.error_log.setLevel(logging.DEBUG)
|
||||
|
||||
def _auth(self, user, password):
|
||||
""" authenticate a user
|
||||
@str user: login of the user
|
||||
@ -360,7 +366,7 @@ class LdapCherry(object):
|
||||
):
|
||||
self.temp[t] = self.temp_lookup.get_template(t)
|
||||
|
||||
def reload(self, config=None):
|
||||
def reload(self, config=None, debug=False):
|
||||
""" load/reload configuration
|
||||
@dict: configuration of ldapcherry
|
||||
"""
|
||||
@ -379,7 +385,7 @@ class LdapCherry(object):
|
||||
# configure access log
|
||||
self._set_access_log(config, level)
|
||||
# configure error log
|
||||
self._set_error_log(config, level)
|
||||
self._set_error_log(config, level, debug)
|
||||
|
||||
# load template files
|
||||
self._load_templates(config)
|
||||
|
@ -17,8 +17,8 @@ from ldapcherry import LdapCherry
|
||||
|
||||
|
||||
def start(configfile=None, daemonize=False, environment=None,
|
||||
fastcgi=False, scgi=False, pidfile=None, imports=None,
|
||||
cgi=False):
|
||||
fastcgi=False, scgi=False, pidfile=None,
|
||||
cgi=False, debug=False):
|
||||
"""Subscribe all engine plugins and start the engine."""
|
||||
sys.path = [''] + sys.path
|
||||
|
||||
@ -47,7 +47,7 @@ def start(configfile=None, daemonize=False, environment=None,
|
||||
instance = LdapCherry()
|
||||
app = cherrypy.tree.mount(instance, '/', configfile)
|
||||
cherrypy.config.update(configfile)
|
||||
instance.reload(app.config)
|
||||
instance.reload(app.config, debug)
|
||||
|
||||
engine = cherrypy.engine
|
||||
|
||||
@ -123,6 +123,8 @@ if __name__ == '__main__':
|
||||
help="store the process id in the given file")
|
||||
p.add_option('-P', '--Path', action="append", dest='Path',
|
||||
help="add the given paths to sys.path")
|
||||
p.add_option('-D', '--debug', action="store_true", dest='debug',
|
||||
help="debug to stderr in foreground")
|
||||
options, args = p.parse_args()
|
||||
|
||||
if options.Path:
|
||||
@ -139,4 +141,4 @@ if __name__ == '__main__':
|
||||
|
||||
start(options.config, options.daemonize,
|
||||
options.environment, options.fastcgi, options.scgi,
|
||||
options.pidfile, options.cgi)
|
||||
options.pidfile, options.cgi, options.debug)
|
||||
|
Loading…
Reference in New Issue
Block a user