mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
Update logging calls to use proper formatting
This commit is contained in:
parent
a4c2e45d6d
commit
e5f1b2afa3
|
@ -196,17 +196,16 @@ class MTProtoSender:
|
|||
self._log.info('Connecting to %s...', self._connection)
|
||||
for attempt in retry_range(self._retries):
|
||||
try:
|
||||
self._log.debug('Connection attempt {}...'.format(attempt))
|
||||
self._log.debug('Connection attempt %d...', attempt)
|
||||
await self._connection.connect(timeout=self._connect_timeout)
|
||||
except (IOError, asyncio.TimeoutError) as e:
|
||||
self._log.warning('Attempt {} at connecting failed: {}: {}'
|
||||
.format(attempt, type(e).__name__, e))
|
||||
self._log.warning('Attempt %d at connecting failed: %s: %s',
|
||||
attempt, type(e).__name__, e)
|
||||
await asyncio.sleep(self._delay)
|
||||
else:
|
||||
break
|
||||
else:
|
||||
raise ConnectionError('Connection to Telegram failed {} time(s)'
|
||||
.format(attempt))
|
||||
raise ConnectionError('Connection to Telegram failed %d time(s)', attempt)
|
||||
|
||||
self._log.debug('Connection success!')
|
||||
if not self.auth_key:
|
||||
|
@ -227,12 +226,10 @@ class MTProtoSender:
|
|||
|
||||
break
|
||||
except (SecurityError, AssertionError) as e:
|
||||
self._log.warning('Attempt {} at new auth_key failed: {}'
|
||||
.format(attempt, e))
|
||||
self._log.warning('Attempt %d at new auth_key failed: %s', attempt, e)
|
||||
await asyncio.sleep(self._delay)
|
||||
else:
|
||||
e = ConnectionError('auth_key generation failed {} time(s)'
|
||||
.format(attempt))
|
||||
e = ConnectionError('auth_key generation failed %d time(s)', attempt)
|
||||
await self._disconnect(error=e)
|
||||
raise e
|
||||
|
||||
|
@ -262,8 +259,7 @@ class MTProtoSender:
|
|||
await self._connection.disconnect()
|
||||
finally:
|
||||
self._connection = None
|
||||
self._log.debug('Cancelling {} pending message(s)...'
|
||||
.format(len(self._pending_state)))
|
||||
self._log.debug('Cancelling %d pending message(s)...', len(self._pending_state))
|
||||
for state in self._pending_state.values():
|
||||
if error and not state.future.done():
|
||||
state.future.set_exception(error)
|
||||
|
@ -332,8 +328,7 @@ class MTProtoSender:
|
|||
|
||||
break
|
||||
else:
|
||||
self._log.error('Automatic reconnection failed {} time(s)'
|
||||
.format(attempt))
|
||||
self._log.error('Automatic reconnection failed %d time(s)', attempt)
|
||||
await self._disconnect(error=last_error.with_traceback(None))
|
||||
|
||||
def _start_reconnect(self, error):
|
||||
|
@ -509,8 +504,7 @@ class MTProtoSender:
|
|||
if not isinstance(reader.tgread_object(), upload.File):
|
||||
raise ValueError('Not an upload.File')
|
||||
except (TypeNotFoundError, ValueError):
|
||||
self._log.info('Received response without parent request: {}'
|
||||
.format(rpc_result.body))
|
||||
self._log.info('Received response without parent request: %s', rpc_result.body)
|
||||
return
|
||||
|
||||
if rpc_result.error:
|
||||
|
@ -549,8 +543,7 @@ class MTProtoSender:
|
|||
await self._process_message(message)
|
||||
|
||||
async def _handle_update(self, message):
|
||||
self._log.debug('Handling update {}'
|
||||
.format(message.obj.__class__.__name__))
|
||||
self._log.debug('Handling update %s', message.obj.__class__.__name__)
|
||||
if self._update_callback:
|
||||
self._update_callback(message.obj)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user