From 9bcd31efc5abcfb529b30c8e067cd421e87d7ed4 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 28 May 2008 13:59:19 -0400 Subject: Fix issue of double logging in ipa_error.log. We open the log in ipa_webgui and this was being inherited by TurboGears which uses the same log so everything was getting logged twice. Shut down the log in ipa_webgui at the last possible moment. This will not catch configuration errors. Add a Not Found template. Only print a traceback on 500 errors. --- ipa-server/ipa-gui/ipa_webgui | 7 +++++ ipa-server/ipa-gui/ipa_webgui.cfg | 2 ++ ipa-server/ipa-gui/ipagui/config/app.cfg | 1 + ipa-server/ipa-gui/ipagui/controllers.py | 16 +++++++--- ipa-server/ipa-gui/ipagui/templates/Makefile.am | 1 + ipa-server/ipa-gui/ipagui/templates/not_found.kid | 37 +++++++++++++++++++++++ 6 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 ipa-server/ipa-gui/ipagui/templates/not_found.kid (limited to 'ipa-server') diff --git a/ipa-server/ipa-gui/ipa_webgui b/ipa-server/ipa-gui/ipa_webgui index 61eaf60c1..5df578956 100644 --- a/ipa-server/ipa-gui/ipa_webgui +++ b/ipa-server/ipa-gui/ipa_webgui @@ -140,11 +140,13 @@ def main(): if devel: logging.basicConfig(level=loglevel, + format='%(asctime)s %(name)s %(levelname)s %(message)s', stream=sys.stderr) else: # This log file name needs to be kept in sync with the one in # ipa_webgui.cfg logging.basicConfig(level=loglevel, + format='%(asctime)s %(name)s %(levelname)s %(message)s', filename='/var/log/ipa_error.log') sys.path.append("/usr/share/ipa") @@ -159,6 +161,11 @@ def main(): import cherrypy cherrypy.lowercase_api = True + # Shut down the logging set up here so that CherryPy logging can take + # over. TurboGears configuration errors will not be caught. + if not devel: + logging.shutdown() + # Load the config - look for a local file first for development # and then the system config file if devel: diff --git a/ipa-server/ipa-gui/ipa_webgui.cfg b/ipa-server/ipa-gui/ipa_webgui.cfg index 101eb825e..5d0f6f8a6 100644 --- a/ipa-server/ipa-gui/ipa_webgui.cfg +++ b/ipa-server/ipa-gui/ipa_webgui.cfg @@ -95,10 +95,12 @@ args='(sys.stdout,)' level='DEBUG' qualname='ipagui' handlers=['debug_out'] +propagate=0 [[[allinfo]]] level='INFO' handlers=['debug_out'] +propagate=0 [[[access]]] level='INFO' diff --git a/ipa-server/ipa-gui/ipagui/config/app.cfg b/ipa-server/ipa-gui/ipagui/config/app.cfg index 03170d376..01bb5ad2c 100644 --- a/ipa-server/ipa-gui/ipagui/config/app.cfg +++ b/ipa-server/ipa-gui/ipagui/config/app.cfg @@ -88,6 +88,7 @@ identity.provider='proxyprovider' # identity associated with a request? Comma separated list of identity sources. # Valid sources: form, visit, http_auth # identity.source="form,http_auth,visit" +identity.source="visit" # compress the data sends to the web browser # [/] diff --git a/ipa-server/ipa-gui/ipagui/controllers.py b/ipa-server/ipa-gui/ipagui/controllers.py index 1ec56b25e..024a804dd 100644 --- a/ipa-server/ipa-gui/ipagui/controllers.py +++ b/ipa-server/ipa-gui/ipagui/controllers.py @@ -84,11 +84,14 @@ class Root(controllers.RootController): """This method is derived from the sample error catcher on http://docs.turbogears.org/1.0/ErrorReporting.""" try: - cherrypy._cputil._cp_on_http_error(status, message) error_msg = self._error_codes.get(status, self._error_codes[None]) url = "%s %s" % (cherrypy.request.method, cherrypy.request.path) - log.exception("CherryPy %s error (%s) for request '%s'", status, - error_msg, url) + if (status == 500): + log.exception("%s error (%s) for request '%s'", status, + error_msg, url) + else: + log.error("%s error (%s) for request '%s'", status, + error_msg, url) if config.get('server.environment') == 'production': details = '' @@ -106,9 +109,14 @@ class Root(controllers.RootController): details = details, ) + if status == 404: + page_template = 'ipagui.templates.not_found' + else: + page_template = 'ipagui.templates.unhandled_exception' + body = controllers._process_output( data, - 'ipagui.templates.unhandled_exception', + page_template, 'html', 'text/html', None diff --git a/ipa-server/ipa-gui/ipagui/templates/Makefile.am b/ipa-server/ipa-gui/ipagui/templates/Makefile.am index 83d546650..ddc8666ca 100644 --- a/ipa-server/ipa-gui/ipagui/templates/Makefile.am +++ b/ipa-server/ipa-gui/ipagui/templates/Makefile.am @@ -25,6 +25,7 @@ app_DATA = \ ipapolicyshow.kid \ loginfailed.kid \ master.kid \ + not_found.kid \ policyindex.kid \ policylayout.kid \ principallayout.kid \ diff --git a/ipa-server/ipa-gui/ipagui/templates/not_found.kid b/ipa-server/ipa-gui/ipagui/templates/not_found.kid new file mode 100644 index 000000000..0bc4c05c0 --- /dev/null +++ b/ipa-server/ipa-gui/ipagui/templates/not_found.kid @@ -0,0 +1,37 @@ + + + + + +Page Not Found + + + +
+

Page Not Found

+
+ ${message} +
+ +
+ + + -- cgit