diff --git a/telegram/__init__.py b/telegram/__init__.py index 03113accd..1eee4c92d 100644 --- a/telegram/__init__.py +++ b/telegram/__init__.py @@ -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'] diff --git a/telegram/bot.py b/telegram/bot.py index 78bdc42e9..7597ddd43 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -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() diff --git a/telegram/nullhandler.py b/telegram/nullhandler.py new file mode 100644 index 000000000..d97ff3e30 --- /dev/null +++ b/telegram/nullhandler.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python + + +import logging + + +class NullHandler(logging.Handler): + def emit(self, record): + pass