Skip to content

Commit 66aaaf9

Browse files
committed
Disable debug and any logging calls in API to fix python-telegram-bot#21
1 parent adcf9b1 commit 66aaaf9

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

telegram/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
from .forcereply import ForceReply
2626
from .inputfile import InputFile
2727
from .error import TelegramError
28+
from .nullhandler import NullHandler
2829
from .emoji import Emoji
2930
from .bot import Bot
3031

3132
__all__ = ['Bot', 'Emoji', 'TelegramError', 'InputFile', 'ReplyMarkup',
3233
'ForceReply', 'ReplyKeyboardHide', 'ReplyKeyboardMarkup',
3334
'UserProfilePhotos', 'ChatAction', 'Location', 'Contact',
3435
'Video', 'Sticker', 'Document', 'Audio', 'PhotoSize', 'GroupChat',
35-
'Update', 'Message', 'User', 'TelegramObject']
36+
'Update', 'Message', 'User', 'TelegramObject', 'NullHandler']

telegram/bot.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
import logging
1717

1818
from telegram import (User, Message, Update, UserProfilePhotos, TelegramError,
19-
ReplyMarkup, InputFile, TelegramObject)
19+
ReplyMarkup, InputFile, TelegramObject, NullHandler)
20+
21+
h = NullHandler()
22+
logging.getLogger(__name__).addHandler(h)
2023

2124

2225
class Bot(TelegramObject):
2326

2427
def __init__(self,
2528
token,
26-
base_url=None,
27-
debug=False):
29+
base_url=None):
2830
self.token = token
2931

3032
if base_url is None:
@@ -33,10 +35,6 @@ def __init__(self,
3335
self.base_url = base_url + self.token
3436

3537
self.log = logging.getLogger(__name__)
36-
if debug:
37-
self.log.setLevel(logging.DEBUG)
38-
else:
39-
self.log.setLevel(logging.INFO)
4038

4139
try:
4240
bot = self.getMe()

telegram/nullhandler.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python
2+
3+
4+
import logging
5+
6+
7+
class NullHandler(logging.Handler):
8+
def emit(self, record):
9+
pass

0 commit comments

Comments
 (0)