Show More
@@ -32,9 +32,15 b' from tornado.escape import url_escape' | |||
|
32 | 32 | from tornado import web |
|
33 | 33 | from tornado import websocket |
|
34 | 34 | |
|
35 | try: | |
|
36 | from tornado.log import app_log | |
|
37 | except ImportError: | |
|
38 | app_log = logging.getLogger() | |
|
39 | ||
|
35 | 40 | from zmq.eventloop import ioloop |
|
36 | 41 | from zmq.utils import jsonapi |
|
37 | 42 | |
|
43 | from IPython.config import Application | |
|
38 | 44 | from IPython.external.decorator import decorator |
|
39 | 45 | from IPython.kernel.zmq.session import Session |
|
40 | 46 | from IPython.lib.security import passwd_check |
@@ -96,7 +102,7 b' if tornado.version_info <= (2,1,1):' | |||
|
96 | 102 | |
|
97 | 103 | websocket.WebSocketHandler._execute = _execute |
|
98 | 104 | del _execute |
|
99 | ||
|
105 | ||
|
100 | 106 | #----------------------------------------------------------------------------- |
|
101 | 107 | # Decorator for disabling read-only handlers |
|
102 | 108 | #----------------------------------------------------------------------------- |
@@ -208,6 +214,14 b' class IPythonHandler(AuthenticatedHandler):' | |||
|
208 | 214 | return self.settings.get('config', None) |
|
209 | 215 | |
|
210 | 216 | @property |
|
217 | def log(self): | |
|
218 | """use the IPython log by default, falling back on tornado's logger""" | |
|
219 | if Application.initialized(): | |
|
220 | return Application.instance().log | |
|
221 | else: | |
|
222 | return app_log | |
|
223 | ||
|
224 | @property | |
|
211 | 225 | def use_less(self): |
|
212 | 226 | """Use less instead of css in templates""" |
|
213 | 227 | return self.settings.get('use_less', False) |
@@ -431,7 +445,7 b' class KernelActionHandler(IPythonHandler):' | |||
|
431 | 445 | |
|
432 | 446 | |
|
433 | 447 | class ZMQStreamHandler(websocket.WebSocketHandler): |
|
434 | ||
|
448 | ||
|
435 | 449 | def clear_cookie(self, *args, **kwargs): |
|
436 | 450 | """meaningless for websockets""" |
|
437 | 451 | pass |
@@ -464,7 +478,7 b' class ZMQStreamHandler(websocket.WebSocketHandler):' | |||
|
464 | 478 | try: |
|
465 | 479 | msg = self._reserialize_reply(msg_list) |
|
466 | 480 | except Exception: |
|
467 |
log |
|
|
481 | self.log.critical("Malformed message: %r" % msg_list, exc_info=True) | |
|
468 | 482 | else: |
|
469 | 483 | self.write_message(msg) |
|
470 | 484 | |
@@ -495,12 +509,12 b' class AuthenticatedZMQStreamHandler(ZMQStreamHandler, IPythonHandler):' | |||
|
495 | 509 | try: |
|
496 | 510 | self.request._cookies = Cookie.SimpleCookie(msg) |
|
497 | 511 | except: |
|
498 |
log |
|
|
512 | self.log.warn("couldn't parse cookie string: %s",msg, exc_info=True) | |
|
499 | 513 | |
|
500 | 514 | def on_first_message(self, msg): |
|
501 | 515 | self._inject_cookie_message(msg) |
|
502 | 516 | if self.get_current_user() is None: |
|
503 |
log |
|
|
517 | self.log.warn("Couldn't authenticate WebSocket connection") | |
|
504 | 518 | raise web.HTTPError(403) |
|
505 | 519 | self.on_message = self.save_on_message |
|
506 | 520 | |
@@ -541,11 +555,11 b' class IOPubHandler(AuthenticatedZMQStreamHandler):' | |||
|
541 | 555 | self.write_message(jsonapi.dumps(msg, default=date_default)) |
|
542 | 556 | |
|
543 | 557 | def on_kernel_restarted(self): |
|
544 |
log |
|
|
558 | self.log.warn("kernel %s restarted", self.kernel_id) | |
|
545 | 559 | self._send_status_message('restarting') |
|
546 | 560 | |
|
547 | 561 | def on_restart_failed(self): |
|
548 |
log |
|
|
562 | self.log.error("kernel %s restarted failed!", self.kernel_id) | |
|
549 | 563 | self._send_status_message('dead') |
|
550 | 564 | |
|
551 | 565 | def on_close(self): |
@@ -878,7 +892,7 b' class FileFindHandler(web.StaticFileHandler):' | |||
|
878 | 892 | try: |
|
879 | 893 | abs_path = filefind(path, roots) |
|
880 | 894 | except IOError: |
|
881 |
log |
|
|
895 | app_log.error("Could not find static file %r", path) | |
|
882 | 896 | return None |
|
883 | 897 | |
|
884 | 898 | # end subclass override |
@@ -891,7 +905,7 b' class FileFindHandler(web.StaticFileHandler):' | |||
|
891 | 905 | hashes[abs_path] = hashlib.md5(f.read()).hexdigest() |
|
892 | 906 | f.close() |
|
893 | 907 | except Exception: |
|
894 |
log |
|
|
908 | app_log.error("Could not open static file %r", path) | |
|
895 | 909 | hashes[abs_path] = None |
|
896 | 910 | hsh = hashes.get(abs_path) |
|
897 | 911 | if hsh: |
General Comments 0
You need to be logged in to leave comments.
Login now