Disable debug and any logging calls in API to fix #21

This commit is contained in:
Leandro Toledo 2015-08-09 09:41:58 -03:00
parent adcf9b1fd5
commit 66aaaf9ec0
3 changed files with 16 additions and 8 deletions

View file

@ -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']

View file

@ -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
View file

@ -0,0 +1,9 @@
#!/usr/bin/env python
import logging
class NullHandler(logging.Handler):
def emit(self, record):
pass