本文整理汇总了Python中http.client.HTTPConnection.debuglevel方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPConnection.debuglevel方法的具体用法?Python HTTPConnection.debuglevel怎么用?Python HTTPConnection.debuglevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http.client.HTTPConnection
的用法示例。
在下文中一共展示了HTTPConnection.debuglevel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enable_debug_requests
# 需要导入模块: from http.client import HTTPConnection [as 别名]
# 或者: from http.client.HTTPConnection import debuglevel [as 别名]
def enable_debug_requests():
# Enabling debugging at http.client level (requests->urllib3->http.client)
# you will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
# the only thing missing will be the response.body which is not logged.
from http.client import HTTPConnection
import logging
HTTPConnection.debuglevel = 1
logger.setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
# 去掉注释,开启调试模式
# enable_debug_requests()
示例2: setup_logger
# 需要导入模块: from http.client import HTTPConnection [as 别名]
# 或者: from http.client.HTTPConnection import debuglevel [as 别名]
def setup_logger(log_level):
if log_level == 'DEBUG':
format = '%(asctime)s %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s'
from http.client import HTTPConnection
HTTPConnection.debuglevel = 1
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
else:
format = click.style('anime', fg='green') + ': %(message)s'
logger = logging.getLogger("anime_downloader")
coloredlogs.install(level=log_level, fmt=format, logger=logger)
示例3: enable_request_debugging
# 需要导入模块: from http.client import HTTPConnection [as 别名]
# 或者: from http.client.HTTPConnection import debuglevel [as 别名]
def enable_request_debugging():
# Enabling debugging at http.client level (requests->urllib3->http.client)
# you will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
# the only thing missing will be the response.body which is not logged.
try: # for Python 3
from http.client import HTTPConnection
except ImportError:
from requests.packages.urllib3.connectionpool import HTTPConnection
HTTPConnection.debuglevel = 1
logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from requests
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
示例4: __init__
# 需要导入模块: from http.client import HTTPConnection [as 别名]
# 或者: from http.client.HTTPConnection import debuglevel [as 别名]
def __init__(self, endpoint=None, key=None, secret=None, token=None, username=None, password=None, timeout=5.0, ssl_verify=True, headers=None, debug=False):
self.endpoint = endpoint or os.environ.get('ALERTA_ENDPOINT', self.DEFAULT_ENDPOINT)
if debug:
HTTPConnection.debuglevel = 1
key = key or os.environ.get('ALERTA_API_KEY', '')
self.http = HTTPClient(self.endpoint, key, secret, token, username, password, timeout, ssl_verify, headers, debug)
# Alerts
示例5: _init_logging
# 需要导入模块: from http.client import HTTPConnection [as 别名]
# 或者: from http.client.HTTPConnection import debuglevel [as 别名]
def _init_logging():
HTTPConnection.debuglevel = 1
logging.basicConfig(level=logging.DEBUG,
format='%(levelname)5s - %(name)s - %(message)s')
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
示例6: main
# 需要导入模块: from http.client import HTTPConnection [as 别名]
# 或者: from http.client.HTTPConnection import debuglevel [as 别名]
def main():
args = parse_args()
if args.verbose:
log.setLevel(logging.DEBUG)
requests_log.setLevel(logging.DEBUG)
HTTPConnection.debuglevel = 2
requests_log.propagate = True
# Safety checks
if args.no_branch and not args.YELPSOA_DIR:
log.error(
"You must specify --yelpsoa-configs-dir to work on if you use the --local option"
)
return False
if args.ticket:
if not args.jira_creds:
raise ValueError("No JIRA creds specified")
# Only import the jira module if we need too
from jira.client import JIRA # noqa: F401
else:
JIRA = None
report = get_report_from_splunk(
args.splunk_creds, args.splunk_app, args.csv_report, args.criteria_filter
)
tmpdir = tempdir() # Create a tmp dir even if we are not using it
working_dir = args.YELPSOA_DIR
if working_dir is None:
# Working in a temporary directory
working_dir = os.path.join("rightsizer", tmpdir.name)
clone_in(working_dir)
with cwd(working_dir):
if args.bulk or args.no_branch:
log.info("Running in bulk mode")
bulk_rightsize(
report, args.create_reviews, args.publish_reviews, not args.no_branch
)
else:
individual_rightsize(
report,
args.ticket,
args.jira_creds,
args.create_reviews,
args.publish_reviews,
JIRA,
)
tmpdir.cleanup() # Cleanup any tmpdire used