mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 21:10:29 +00:00
Add logging to MTProtoSender
This commit is contained in:
21
telethon/log.py
Normal file
21
telethon/log.py
Normal 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()
|
Reference in New Issue
Block a user