def test_add_stderr_logger(self): handler = add_stderr_logger(level=logging.INFO) # Don't actually print debug logger = logging.getLogger('urllib3') assert handler in logger.handlers logger.debug('Testing add_stderr_logger') logger.removeHandler(handler)
def test_add_stderr_logger(self): handler = add_stderr_logger(level=logging.INFO) # Don't actually print debug logger = logging.getLogger("urllib3") self.assertTrue(handler in logger.handlers) logger.debug("Testing add_stderr_logger") logger.removeHandler(handler)
def setup_logging_levels(snaptool_level, snapshots_level=logging.ERROR, background_level=logging.ERROR, wekalib_level=logging.ERROR): log.setLevel(snaptool_level) log.info( " ---------------------- Setting new log levels ----------------------------" ) urllib3.add_stderr_logger(level=logging.ERROR) logging.getLogger("wekalib.wekacluster").setLevel(wekalib_level) logging.getLogger("wekalib.wekaapi").setLevel(wekalib_level) logging.getLogger("wekalib.sthreads").setLevel(wekalib_level) logging.getLogger("wekalib.circular").setLevel(wekalib_level) logging.getLogger("background").setLevel(background_level) logging.getLogger("snapshots").setLevel(snapshots_level)
def test_add_stderr_logger(self) -> None: handler = add_stderr_logger( level=logging.INFO) # Don't actually print debug logger = logging.getLogger("urllib3") assert handler in logger.handlers logger.debug("Testing add_stderr_logger") logger.removeHandler(handler)
def http_debug_log_stderr(): """Dump requests urllib3 debug messages to stderr""" urllib3.add_stderr_logger()
__author__ = 'wenzhouyang' #with python 3.4 import urllib3 import logging urllib3.add_stderr_logger(level=logging.DEBUG) userAgent = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36' headers = urllib3.make_headers(user_agent=userAgent) requestHeaders = {'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding':'gzip,deflate,sdch', 'Accept-Language':'zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4', 'Cache-Control':'max-age=0', 'User-agent':userAgent, 'Cookie':'cookie_name=cookie_value'} http = urllib3.PoolManager() r = http.request('GET', 'http://localhost:8081/manage/sayHello', headers=requestHeaders) cookie = r.getheader('Set-Cookie') requestHeaders['Cookie'] = cookie print(requestHeaders) r = http.request('GET', 'http://localhost:8081/manage/sayHello', headers=requestHeaders) print(cookie) print(r.data) #HTML