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