本文整理匯總了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