Add NullHandler to loggers to prevent spurious error messages

Supporting python 2.6+
This commit is contained in:
Michael Komitee
2013-03-20 21:41:01 -04:00
parent 5999581686
commit 2cf665e5c8
2 changed files with 19 additions and 0 deletions

View File

@@ -12,9 +12,14 @@ authentication. Basic GET usage:
The entire `requests.api` should be supported.
"""
import logging
import sys
from .kerberos_ import HTTPKerberosAuth, REQUIRED, OPTIONAL, DISABLED
from .exceptions import MutualAuthenticationError
from .compat import NullHandler
logging.getLogger(__name__).addHandler(NullHandler())
__all__ = [HTTPKerberosAuth, MutualAuthenticationError, REQUIRED, OPTIONAL, DISABLED]
__version__ = '0.1'

View File

@@ -0,0 +1,14 @@
"""
Compatibility library for older versions of python
"""
import sys
# python 2.7 introduced a NullHandler which we want to use, but to support
# older versions, we implement our own if needed.
if sys.version_info[:2] > (2, 6):
from logging import NullHandler
else:
from logging import Handler
class NullHandler(Handler):
def emit(self, record):
pass