Fix-up missing loggers from f271316

This commit is contained in:
Lonami Exo 2019-01-12 12:15:29 +01:00
parent f271316d7d
commit ae4d4ba3ef
4 changed files with 9 additions and 8 deletions

View File

@ -189,7 +189,8 @@ class TelegramBaseClient(abc.ABC):
class _Loggers(dict): class _Loggers(dict):
def __missing__(self, key): def __missing__(self, key):
if key.startswith("telethon."): if key.startswith("telethon."):
key = key[len("telethon."):] key = key.split('.', maxsplit=1)[1]
return base_logger.getChild(key) return base_logger.getChild(key)
self._log = _Loggers() self._log = _Loggers()
@ -466,7 +467,7 @@ class TelegramBaseClient(abc.ABC):
# #
# If one were to do that, Telegram would reset the connection # If one were to do that, Telegram would reset the connection
# with no further clues. # with no further clues.
sender = MTProtoSender(None, self._loop) sender = MTProtoSender(None, self._loop, loggers=self._log)
await sender.connect(self._connection( await sender.connect(self._connection(
dc.ip_address, dc.port, loop=self._loop, proxy=self._proxy)) dc.ip_address, dc.port, loop=self._loop, proxy=self._proxy))
self._log[__name__].info('Exporting authorization for data center %s', self._log[__name__].info('Exporting authorization for data center %s',
@ -528,7 +529,7 @@ class TelegramBaseClient(abc.ABC):
await session.set_dc(dc.id, dc.ip_address, dc.port) await session.set_dc(dc.id, dc.ip_address, dc.port)
self._exported_sessions[cdn_redirect.dc_id] = session self._exported_sessions[cdn_redirect.dc_id] = session
__log__.info('Creating new CDN client') self._log[__name__].info('Creating new CDN client')
client = TelegramBareClient( client = TelegramBareClient(
session, self.api_id, self.api_hash, session, self.api_id, self.api_hash,
proxy=self._sender.connection.conn.proxy, proxy=self._sender.connection.conn.proxy,

View File

@ -136,9 +136,9 @@ class Connection(abc.ABC):
pass pass
except Exception as e: except Exception as e:
if isinstance(e, ConnectionError): if isinstance(e, ConnectionError):
__log__.info('The server closed the connection while sending') self._log.info('The server closed the connection while sending')
else: else:
__log__.exception('Unexpected exception in the send loop') self._log.exception('Unexpected exception in the send loop')
self.disconnect() self.disconnect()

View File

@ -14,13 +14,13 @@ class MTProtoPlainSender:
MTProto Mobile Protocol plain sender MTProto Mobile Protocol plain sender
(https://core.telegram.org/mtproto/description#unencrypted-messages) (https://core.telegram.org/mtproto/description#unencrypted-messages)
""" """
def __init__(self, connection): def __init__(self, connection, *, loggers):
""" """
Initializes the MTProto plain sender. Initializes the MTProto plain sender.
:param connection: the Connection to be used. :param connection: the Connection to be used.
""" """
self._state = MTProtoState(auth_key=None) self._state = MTProtoState(auth_key=None, loggers=loggers)
self._connection = connection self._connection = connection
async def send(self, request): async def send(self, request):

View File

@ -227,7 +227,7 @@ class MTProtoSender:
self._log.debug('Connection success!') self._log.debug('Connection success!')
if not self.auth_key: if not self.auth_key:
plain = MTProtoPlainSender(self._connection) plain = MTProtoPlainSender(self._connection, loggers=self._loggers)
for retry in range(1, self._retries + 1): for retry in range(1, self._retries + 1):
try: try:
self._log.debug('New auth_key attempt {}...'.format(retry)) self._log.debug('New auth_key attempt {}...'.format(retry))