Changeset 805
- Timestamp:
- 11/10/05 00:04:09
- Files:
-
- trunk/cherrypy/_cphttptools.py (modified) (1 diff)
- trunk/cherrypy/_cputil.py (modified) (1 diff)
- trunk/cherrypy/test/test_core.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cphttptools.py
r794 r805 1 1 """CherryPy core request/response handling.""" 2 2 3 import cgi4 3 import Cookie 5 4 import os 6 import re7 5 import sys 8 6 import types trunk/cherrypy/_cputil.py
r800 r805 306 306 def _cpOnError(): 307 307 """ Default _cpOnError method """ 308 # Allow logging of only *unexpected* HTTPError's. 309 if (not cherrypy.config.get('server.logTracebacks', True) 310 and cherrypy.config.get('server.logUnhandledTracebacks', True)): 311 cherrypy.log(formatExc()) 312 308 313 cherrypy.HTTPError(500).set_response() 309 314 trunk/cherrypy/test/test_core.py
r801 r805 171 171 # Since status must start with an int, this should error. 172 172 cherrypy.response.status = "ZOO OK" 173 174 def log_unhandled(self): 175 raise ValueError() 173 176 174 177 … … 353 356 'errorPage.404': "nonexistent.html", 354 357 }, 358 '/error/log_unhandled': { 359 'server.logTracebacks': False, 360 'server.logUnhandledTracebacks': True, 361 }, 355 362 }) 356 363 … … 453 460 self.assertEqual(data, []) 454 461 455 # Test that tracebacks get written to the error log.456 462 ignore = helper.webtest.ignored_exceptions 457 463 ignore.append(ValueError) 458 464 try: 465 # Test that tracebacks get written to the error log. 459 466 self.getPage("/error/page_method") 460 467 self.assertInBody("raise ValueError()") … … 462 469 self.assertEqual(data[0][-41:], ' INFO Traceback (most recent call last):\n') 463 470 self.assertEqual(data[6], ' raise ValueError()\n') 471 472 # Test that unhandled tracebacks get written to the error log 473 # if logTracebacks is False but logUnhandledTracebacks is True. 474 self.getPage("/error/log_unhandled") 475 self.assertInBody("raise ValueError()") 476 data = open(logFile, "rb").readlines() 477 self.assertEqual(data[9][-41:], ' INFO Traceback (most recent call last):\n') 478 self.assertEqual(data[15], ' raise ValueError()\n') 479 # Each error should write only one traceback (9 lines each). 480 self.assertEqual(len(data), 18) 464 481 finally: 465 482 ignore.pop()

