Changeset 1692
- Timestamp:
- 06/25/07 12:41:43
- Files:
-
- trunk/cherrypy/__init__.py (modified) (2 diffs)
- trunk/cherrypy/restsrv/wspbus.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/__init__.py
r1690 r1692 233 233 234 234 engine.subscribe('start', server.quickstart) 235 236 s = restsrv.plugins.SignalHandler(engine) 237 s.set_handler('SIGTERM', engine.stop) 238 s.set_handler('SIGHUP', engine.restart) 239 235 restsrv.plugins.SignalHandler(engine) 240 236 engine.start() 241 237 engine.block() … … 383 379 # Using an access file makes CP about 10% slower. Leave off by default. 384 380 log.access_file = '' 385 engine.log = lambda msg, traceback=False: log.error(msg, 'ENGINE', 386 traceback=traceback) 381 engine.subscribe('log', lambda msg: log.error(msg, 'ENGINE')) 387 382 388 383 # Helper functions for CP apps # trunk/cherrypy/restsrv/wspbus.py
r1690 r1692 57 57 import threading 58 58 import time 59 import traceback 59 import traceback as _traceback 60 60 61 61 … … 79 79 def __init__(self): 80 80 self.state = states.STOPPED 81 self.listeners = dict( [(channel, set()) for channel82 in ('start', 'stop', 'exit',83 'restart', 'graceful')])81 self.listeners = dict( 82 [(channel, set()) for channel 83 in ('start', 'stop', 'exit', 'restart', 'graceful')]) 84 84 self._priorities = {} 85 85 … … 199 199 200 200 def log(self, msg="", traceback=False): 201 """Log the given message. Append the last traceback if requested.""" 201 202 if traceback: 202 msg = '\n'.join((msg, format_exc())) 203 print msg 204 205 206 def format_exc(exc=None): 207 """Return exc (or sys.exc_info if None), formatted.""" 208 if exc is None: 209 exc = sys.exc_info() 210 if exc == (None, None, None): 211 return "" 212 return "".join(traceback.format_exception(*exc)) 203 exc = sys.exc_info() 204 msg += "\n" + "".join(_traceback.format_exception(*exc)) 205 self.publish('log', msg) 213 206 214 207 bus = Bus() 215

