Add NullHandler to loggers to prevent spurious error messages
Supporting python 2.6+
This commit is contained in:
@@ -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'
|
||||
|
||||
14
requests_kerberos/compat.py
Normal file
14
requests_kerberos/compat.py
Normal 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
|
||||
Reference in New Issue
Block a user