Skip to content

Commit

Permalink
Merge pull request #90 from j9ac9k/unindent-websockethandler
Browse files Browse the repository at this point in the history
unindent WebSocketHandler definition
  • Loading branch information
j9ac9k authored Apr 18, 2024
2 parents 16e227e + 0f8952c commit c44cde3
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/codem/lib/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
except ImportError:
pass
else:

class CustomJsonFormatter(jsonlogger.JsonFormatter):
def add_fields(
self,
Expand All @@ -39,20 +38,21 @@ def add_fields(
log_record["type"] = "log_message"
return None

class WebSocketHandler(logging.Handler):
def __init__(self, level: str, websocket: "websocket.WebSocket") -> None:
super().__init__(level)
self.ws = websocket
# TODO: check if websocket is already connected?

def emit(self, record: logging.LogRecord) -> None:
msg = self.format(record)
_ = self.ws.send(msg)
return None
class WebSocketHandler(logging.Handler):
def __init__(self, level: str, websocket: "websocket.WebSocket") -> None:
super().__init__(level)
self.ws = websocket
# TODO: check if websocket is already connected?

def emit(self, record: logging.LogRecord) -> None:
msg = self.format(record)
_ = self.ws.send(msg)
return None

def close(self) -> None:
self.ws.close()
return super().close()
def close(self) -> None:
self.ws.close()
return super().close()


class Log:
Expand Down

0 comments on commit c44cde3

Please sign in to comment.