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