Commits

Jeffrey Gelens committed 710261e

Make logger available in Websocket Class

  • Participants
  • Parent commits 41a9655

Comments (0)

Files changed (2)

File geventwebsocket/handler.py

 
             return [msg]
 
-        self.websocket = WebSocket(self.environ, Stream(self))
+        self.websocket = WebSocket(self.environ, Stream(self), self)
 
         self.environ.update({
             'wsgi.websocket_version': version,

File geventwebsocket/websocket.py

     """
 
     __slots__ = ('utf8validator', 'utf8validate_last', 'environ', 'closed',
-                 'stream', 'raw_write', 'raw_read')
+                 'stream', 'raw_write', 'raw_read', 'handler')
 
     OPCODE_CONTINUATION = 0x00
     OPCODE_TEXT = 0x01
     OPCODE_PING = 0x09
     OPCODE_PONG = 0x0a
 
-    def __init__(self, environ, stream):
+    def __init__(self, environ, stream, handler):
         self.environ = environ
         self.closed = False
 
         self.raw_read = stream.read
 
         self.utf8validator = Utf8Validator()
+        self.handler = handler
 
     def __del__(self):
         try:
 
         return self.environ.get('PATH_INFO')
 
+    @property
+    def logger(self):
+        return self.handler.logger
+
     def handle_close(self, header, payload):
         """
         Called when a close frame has been decoded from the stream.
         except WebSocketError:
             # Failed to write the closing frame but it's ok because we're
             # closing the socket anyway.
-            pass
+            self.logger.debug("Failed to write closing frame -> closing socket")
         finally:
+            self.logger.debug("Closed WebSocket")
             self.closed = True
 
             self.stream = None