Add logging to MTProtoSender

This commit is contained in:
Lonami Exo
2017-04-09 13:14:04 +02:00
parent 6add278f07
commit 1232e8f607
2 changed files with 54 additions and 2 deletions

21
telethon/log.py Normal file
View File

@@ -0,0 +1,21 @@
import sys
import logging
for arg in sys.argv:
if arg.startswith('--telethon-log='):
level = getattr(logging, arg.split('=')[1], None)
if not isinstance(level, int):
raise ValueError('Invalid log level: %s' % level)
print('Using log level', level, 'which is', arg.split('=')[1])
logging.basicConfig(level=level)
class Logger:
def __init__(self):
setattr(self, 'd', logging.debug)
setattr(self, 'i', logging.info)
setattr(self, 'w', logging.warning)
setattr(self, 'e', logging.error)
Log = Logger()