From 7a199fe5676aaac32b4adc73e95bf4ca9f2033c3 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 15 Aug 2022 10:21:36 -0400 Subject: [PATCH] Change a lot of logging INFO calls to be less verbose Some of the logs were only useful for debug scenarios, so they have been downgraded to DEBUG. Others were in INFO but supposed to be in WARNING so those were upgraded. --- discord/client.py | 2 +- discord/gateway.py | 16 ++++++++-------- discord/opus.py | 6 +++--- discord/player.py | 10 +++++----- discord/voice_client.py | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/discord/client.py b/discord/client.py index 28375879e..20aa73c4d 100644 --- a/discord/client.py +++ b/discord/client.py @@ -780,7 +780,7 @@ class Client: while True: await self.ws.poll_event() except ReconnectWebSocket as e: - _log.info('Got a request to %s the websocket.', e.op) + _log.debug('Got a request to %s the websocket.', e.op) self.dispatch('disconnect') ws_params.update(sequence=self.ws.sequence, resume=e.resume, session=self.ws.session_id) if e.resume: diff --git a/discord/gateway.py b/discord/gateway.py index d5a6aac1a..69892541e 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -487,7 +487,7 @@ class DiscordWebSocket: await self.call_hooks('before_identify', initial=self._initial_identify) await self.send_as_json(payload) - _log.info('Gateway has sent the IDENTIFY payload.') + _log.debug('Gateway has sent the IDENTIFY payload.') async def resume(self) -> None: """Sends the RESUME packet.""" @@ -501,7 +501,7 @@ class DiscordWebSocket: } await self.send_as_json(payload) - _log.info('Gateway has sent the RESUME payload.') + _log.debug('Gateway has sent the RESUME payload.') async def received_message(self, msg: Any, /) -> None: if type(msg) is bytes: @@ -654,15 +654,15 @@ class DiscordWebSocket: self._keep_alive = None if isinstance(e, asyncio.TimeoutError): - _log.info('Timed out receiving packet. Attempting a reconnect.') + _log.debug('Timed out receiving packet. Attempting a reconnect.') raise ReconnectWebSocket from None code = self._close_code or self.socket.close_code if self._can_handle_close(): - _log.info('Websocket closed with %s, attempting a reconnect.', code) + _log.debug('Websocket closed with %s, attempting a reconnect.', code) raise ReconnectWebSocket from None else: - _log.info('Websocket closed with %s, cannot reconnect.', code) + _log.debug('Websocket closed with %s, cannot reconnect.', code) raise ConnectionClosed(self.socket, code=code) from None async def debug_send(self, data: str, /) -> None: @@ -1029,7 +1029,7 @@ class DiscordVoiceWebSocket: if self._keep_alive: self._keep_alive.ack() elif op == self.RESUMED: - _log.info('Voice RESUME succeeded.') + _log.debug('Voice RESUME succeeded.') elif op == self.SESSION_DESCRIPTION: self._connection.mode = data['mode'] await self.load_secret_key(data) @@ -1068,7 +1068,7 @@ class DiscordVoiceWebSocket: mode = modes[0] await self.select_protocol(state.ip, state.port, mode) - _log.info('Selected the voice protocol for use: %s.', mode) + _log.debug('Selected the voice protocol for use: %s.', mode) @property def latency(self) -> float: @@ -1086,7 +1086,7 @@ class DiscordVoiceWebSocket: return sum(heartbeat.recent_ack_latencies) / len(heartbeat.recent_ack_latencies) async def load_secret_key(self, data: Dict[str, Any]) -> None: - _log.info('Received secret key for voice connection.') + _log.debug('Received secret key for voice connection.') self.secret_key = self._connection.secret_key = data['secret_key'] await self.speak() await self.speak(SpeakingState.none) diff --git a/discord/opus.py b/discord/opus.py index b9cf2124f..7cbdd8386 100644 --- a/discord/opus.py +++ b/discord/opus.py @@ -122,7 +122,7 @@ signal_ctl: SignalCtl = { def _err_lt(result: int, func: Callable, args: List) -> int: if result < OK: - _log.info('error has happened in %s', func.__name__) + _log.debug('error has happened in %s', func.__name__) raise OpusError(result) return result @@ -130,7 +130,7 @@ def _err_lt(result: int, func: Callable, args: List) -> int: def _err_ne(result: T, func: Callable, args: List) -> T: ret = args[-1]._obj if ret.value != OK: - _log.info('error has happened in %s', func.__name__) + _log.debug('error has happened in %s', func.__name__) raise OpusError(ret.value) return result @@ -291,7 +291,7 @@ class OpusError(DiscordException): def __init__(self, code: int): self.code: int = code msg = _lib.opus_strerror(self.code).decode('utf-8') - _log.info('"%s" has happened', msg) + _log.debug('"%s" has happened', msg) super().__init__(msg) diff --git a/discord/player.py b/discord/player.py index b1f02c3af..0e83fd846 100644 --- a/discord/player.py +++ b/discord/player.py @@ -189,7 +189,7 @@ class FFmpegAudio(AudioSource): if proc is MISSING: return - _log.info('Preparing to terminate ffmpeg process %s.', proc.pid) + _log.debug('Preparing to terminate ffmpeg process %s.', proc.pid) try: proc.kill() @@ -533,9 +533,9 @@ class FFmpegOpusAudio(FFmpegAudio): except Exception: _log.exception("Fallback probe using '%s' failed", executable) else: - _log.info("Fallback probe found codec=%s, bitrate=%s", codec, bitrate) + _log.debug("Fallback probe found codec=%s, bitrate=%s", codec, bitrate) else: - _log.info("Probe found codec=%s, bitrate=%s", codec, bitrate) + _log.debug("Probe found codec=%s, bitrate=%s", codec, bitrate) finally: return codec, bitrate @@ -745,5 +745,5 @@ class AudioPlayer(threading.Thread): def _speak(self, speaking: SpeakingState) -> None: try: asyncio.run_coroutine_threadsafe(self.client.ws.speak(speaking), self.client.client.loop) - except Exception as e: - _log.info("Speaking call in player failed: %s", e) + except Exception: + _log.exception('Speaking call in player failed.') diff --git a/discord/voice_client.py b/discord/voice_client.py index b7c0eb0ad..6d660c50e 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -307,7 +307,7 @@ class VoiceClient(VoiceProtocol): async def on_voice_server_update(self, data: VoiceServerUpdatePayload) -> None: if self._voice_server_complete.is_set(): - _log.info('Ignoring extraneous voice server update.') + _log.warning('Ignoring extraneous voice server update.') return self.token = data['token']