Created
April 21, 2013 00:42
-
-
Save tadeck/5427998 to your computer and use it in GitHub Desktop.
The snippet adding support for logging even if code using it does not add handlers to module's logger. Shamelessly copied from python-requests.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set default logging handler to avoid "No handler found" warnings. | |
import logging | |
try: # Python 2.7+ | |
from logging import NullHandler | |
except ImportError: | |
class NullHandler(logging.Handler): | |
def emit(self, record): | |
pass | |
logging.getLogger(__name__).addHandler(NullHandler()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment