def error(self, msg='', context='', severity=logging.INFO, traceback=False): """Write the given ``msg`` to the error log. This is not just for errors! Applications may call this at any time to log application-specific information. If ``traceback`` is True, the traceback of the current exception (if any) will be appended to ``msg``. """ exc_info = None if traceback: exc_info = _cperror._exc_info() self.error_log.log(severity, ' '.join((self.time(), context, msg)), exc_info=exc_info)
def errorPage(self, **kwargs): self.logger.debug(_cperror.format_exc()) try: args = { "message": kwargs['status'], "details": "Please consult the log files for more information.", "hint": '', "automatic_reload": False, } exception_class = _cperror._exc_info()[0] if issubclass(exception_class, DatabaseError): args[ 'details'] = "An database error occured, please consult the log files." args[ 'hint'] = "Maybe the database schema needs to be updated after an code update?" elif args["message"].startswith("4"): args["details"] = kwargs["message"] try: template_context, category_dict, run = self.category.prepareDisplay( ) template_context.update(args) filename = os.path.join( hf.hf_dir, hf.config.get("paths", "hf_template_dir"), "error.html") template = Template(filename=filename, lookup=hf.template_lookup) return template.render_unicode( **template_context).encode("utf-8") except Exception, e: self.logger.debug("Fancy error page generation failed\n" + traceback.format_exc()) filename = os.path.join( hf.hf_dir, hf.config.get("paths", "hf_template_dir"), "plain_error.html") template = Template(filename=filename, lookup=hf.template_lookup) return template.render_unicode(**args).encode("utf-8") except Exception, e: self.logger.error(u"error page generation failed: " + unicode(e)) self.logger.error(traceback.format_exc()) return u"""<h1>Error Inception</h1> <p>An error occured while displaying an error. Embarrasing.</p> <p>Please consult the log files!</p>""".encode("utf-8")
def errorPage(self, **kwargs): self.logger.debug(_cperror.format_exc()) try: args = { "message": kwargs['status'], "details": "Please consult the log files for more information.", "hint": '', "automatic_reload": False, } exception_class = _cperror._exc_info()[0] if issubclass(exception_class, DatabaseError): args['details'] = "An database error occured, please consult the log files." args['hint'] = "Maybe the database schema needs to be updated after an code update?" elif args["message"].startswith("4"): args["details"] = kwargs["message"] try: template_context, category_dict, run = self.category.prepareDisplay() template_context.update(args) filename = os.path.join(hf.hf_dir, hf.config.get("paths", "hf_template_dir"), "error.html") template = Template(filename=filename, lookup=hf.template_lookup) return template.render_unicode(**template_context).encode("utf-8") except Exception, e: self.logger.debug("Fancy error page generation failed\n" + traceback.format_exc()) filename = os.path.join(hf.hf_dir, hf.config.get("paths", "hf_template_dir"), "plain_error.html") template = Template(filename=filename, lookup=hf.template_lookup) return template.render_unicode(**args).encode("utf-8") except Exception, e: self.logger.error(u"error page generation failed: " + unicode(e)) self.logger.error(traceback.format_exc()) return u"""<h1>Error Inception</h1> <p>An error occured while displaying an error. Embarrasing.</p> <p>Please consult the log files!</p>""".encode("utf-8")