mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 06:25:12 +01:00
Disable debug and any logging calls in API to fix #21
This commit is contained in:
parent
adcf9b1fd5
commit
66aaaf9ec0
3 changed files with 16 additions and 8 deletions
|
@ -25,6 +25,7 @@ from .replykeyboardhide import ReplyKeyboardHide
|
|||
from .forcereply import ForceReply
|
||||
from .inputfile import InputFile
|
||||
from .error import TelegramError
|
||||
from .nullhandler import NullHandler
|
||||
from .emoji import Emoji
|
||||
from .bot import Bot
|
||||
|
||||
|
@ -32,4 +33,4 @@ __all__ = ['Bot', 'Emoji', 'TelegramError', 'InputFile', 'ReplyMarkup',
|
|||
'ForceReply', 'ReplyKeyboardHide', 'ReplyKeyboardMarkup',
|
||||
'UserProfilePhotos', 'ChatAction', 'Location', 'Contact',
|
||||
'Video', 'Sticker', 'Document', 'Audio', 'PhotoSize', 'GroupChat',
|
||||
'Update', 'Message', 'User', 'TelegramObject']
|
||||
'Update', 'Message', 'User', 'TelegramObject', 'NullHandler']
|
||||
|
|
|
@ -16,15 +16,17 @@ import functools
|
|||
import logging
|
||||
|
||||
from telegram import (User, Message, Update, UserProfilePhotos, TelegramError,
|
||||
ReplyMarkup, InputFile, TelegramObject)
|
||||
ReplyMarkup, InputFile, TelegramObject, NullHandler)
|
||||
|
||||
h = NullHandler()
|
||||
logging.getLogger(__name__).addHandler(h)
|
||||
|
||||
|
||||
class Bot(TelegramObject):
|
||||
|
||||
def __init__(self,
|
||||
token,
|
||||
base_url=None,
|
||||
debug=False):
|
||||
base_url=None):
|
||||
self.token = token
|
||||
|
||||
if base_url is None:
|
||||
|
@ -33,10 +35,6 @@ class Bot(TelegramObject):
|
|||
self.base_url = base_url + self.token
|
||||
|
||||
self.log = logging.getLogger(__name__)
|
||||
if debug:
|
||||
self.log.setLevel(logging.DEBUG)
|
||||
else:
|
||||
self.log.setLevel(logging.INFO)
|
||||
|
||||
try:
|
||||
bot = self.getMe()
|
||||
|
|
9
telegram/nullhandler.py
Normal file
9
telegram/nullhandler.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
class NullHandler(logging.Handler):
|
||||
def emit(self, record):
|
||||
pass
|
Loading…
Reference in a new issue