mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-08 01:09:44 +08:00
remove setup_logger in main_hrun()
This commit is contained in:
@@ -5,7 +5,7 @@ def main_hrun():
|
|||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
from httprunner import logger
|
from httprunner.logger import color_print
|
||||||
from httprunner import __description__, __version__
|
from httprunner import __description__, __version__
|
||||||
from httprunner.api import HttpRunner
|
from httprunner.api import HttpRunner
|
||||||
from httprunner.compat import is_py2
|
from httprunner.compat import is_py2
|
||||||
@@ -52,13 +52,12 @@ def main_hrun():
|
|||||||
help="Prettify JSON testcase format.")
|
help="Prettify JSON testcase format.")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
logger.setup_logger(args.log_level, args.log_file)
|
|
||||||
|
|
||||||
if is_py2:
|
if is_py2:
|
||||||
logger.log_warning(get_python2_retire_msg())
|
color_print(get_python2_retire_msg(), "YELLOW")
|
||||||
|
|
||||||
if args.version:
|
if args.version:
|
||||||
logger.color_print("{}".format(__version__), "GREEN")
|
color_print("{}".format(__version__), "GREEN")
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
if args.validate:
|
if args.validate:
|
||||||
@@ -77,13 +76,15 @@ def main_hrun():
|
|||||||
failfast=args.failfast,
|
failfast=args.failfast,
|
||||||
save_tests=args.save_tests,
|
save_tests=args.save_tests,
|
||||||
report_template=args.report_template,
|
report_template=args.report_template,
|
||||||
report_dir=args.report_dir
|
report_dir=args.report_dir,
|
||||||
|
log_level=args.log_level,
|
||||||
|
log_file=args.log_file
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
for path in args.testcase_paths:
|
for path in args.testcase_paths:
|
||||||
runner.run(path, dot_env_path=args.dot_env_path)
|
runner.run(path, dot_env_path=args.dot_env_path)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.log_error("!!!!!!!!!! exception stage: {} !!!!!!!!!!".format(runner.exception_stage))
|
color_print("!!!!!!!!!! exception stage: {} !!!!!!!!!!".format(runner.exception_stage), "YELLOW")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if runner.summary and runner.summary["success"]:
|
if runner.summary and runner.summary["success"]:
|
||||||
|
|||||||
@@ -19,10 +19,7 @@ logger = logging.getLogger("httprunner")
|
|||||||
|
|
||||||
|
|
||||||
def setup_logger(log_level, log_file=None):
|
def setup_logger(log_level, log_file=None):
|
||||||
"""setup root logger with ColoredFormatter."""
|
"""setup logger with ColoredFormatter."""
|
||||||
if len(logger.handlers) > 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
level = getattr(logging, log_level.upper(), None)
|
level = getattr(logging, log_level.upper(), None)
|
||||||
if not level:
|
if not level:
|
||||||
color_print("Invalid log level: %s" % log_level, "RED")
|
color_print("Invalid log level: %s" % log_level, "RED")
|
||||||
|
|||||||
Reference in New Issue
Block a user