'Where log messages should go.'
ALL = auto()
DEBUG = auto()
- RAW = auto()
CHAT = auto()
USER = auto()
USER_NO_CHANNELS = auto()
def __init__(self, scope: _LogScope, **kwargs) -> None:
self.scope = scope
super().__init__(**kwargs)
- self._title = f'{self.client_id} '\
- + f':{"DEBUG" if self.scope == _LogScope.DEBUG else "RAW"}'
+ self._title = f'{self.client_id} :DEBUG'
def _send_msg(self, verb: str, params: tuple[str, ...]) -> None:
self._client_trigger('send_w_params_tuple', verb=verb, params=params)
if scope == _LogScope.ALL:
ret = [w for w in self.windows
if w not in self.windows_for(_LogScope.DEBUG)]
- elif scope == _LogScope.RAW:
- ret = self.windows_for(_LogScope.DEBUG)
elif scope == _LogScope.DEBUG:
ret = [w for w in self.windows if w.scope == _LogScope.DEBUG]
elif scope == _LogScope.CHAT:
def log(self, msg: str, **kwargs) -> tuple[tuple[int, ...], str]:
win_ids, logged_msg = super().log(msg, **kwargs)
- if kwargs.get('scope', None) == _LogScope.RAW:
+ if kwargs.get('scope', None) == _LogScope.DEBUG\
+ and kwargs['prefix'] in {_LOG_PREFIX_IN, _LOG_PREFIX_OUT}:
with open(f'{kwargs["client_id"]}.log', 'a', encoding='utf8') as f:
f.write(f'{logged_msg}\n')
return win_ids, logged_msg
def send(self, verb: str, *args) -> IrcMessage:
msg = super().send(verb, *args)
- self._log(msg.raw, scope=_LogScope.RAW, out=True)
+ self._log(msg.raw, scope=_LogScope.DEBUG, out=True)
return msg
def handle_msg(self, msg: IrcMessage) -> None:
- self._log(msg.raw, scope=_LogScope.RAW, out=False)
+ self._log(msg.raw, scope=_LogScope.DEBUG, out=False)
try:
super().handle_msg(msg)
except ImplementationFail as e: