一段不熟悉的logging用法( 猜测是给库打log 用的 )
弄清楚该段 logging 代码的作用原理( 虽然有句注释 # Set default logging handler to avoid "No handler found" warnings. )
requests.__init__.py中的用法
# 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())
产品版本: requests最新
操作系统: Linux
Python: 2.7.x
This means that if your current version of the logging module does not have a NullHandler, write one yourself. In short, ensure that the subsequent code has a NullHandler available