From 46ec1a74a4315e66c251f7ee056ee7165658bd19 Mon Sep 17 00:00:00 2001 From: codeskyblue Date: Tue, 28 Nov 2023 19:38:17 +0800 Subject: [PATCH] update console arg name and indent code --- tidevice/__main__.py | 20 ++++++++++---------- tidevice/_device.py | 18 +++++++++--------- tidevice/_proto.py | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tidevice/__main__.py b/tidevice/__main__.py index 66efc4f..e304e9c 100644 --- a/tidevice/__main__.py +++ b/tidevice/__main__.py @@ -251,20 +251,20 @@ def cmd_xcuitest(args: argparse.Namespace): log_level = logging.DEBUG if args.debug else logging.INFO setup_logger(LOG.xcuitest, level=log_level) - if args.test_process_log_path: - logger.info('XCUITest test process log file path: %s', args.test_process_log_path) + if args.process_log_path: + logger.info('XCUITest test process log file path: %s', args.process_log_path) # Use the default formatter that is a no-op formatter. - setup_logger(LOG.xcuitest_test_process_log, - logfile=args.test_process_log_path, + setup_logger(LOG.xcuitest_process_log, + logfile=args.process_log_path, disableStderrLogger=True, # Disable console logging. level=log_level, formatter=logging.Formatter()) - if args.test_output_path: - logger.info('XCUITest test output file path: %s', args.test_output_path) + if args.console_log_path: + logger.info('XCUITest test output file path: %s', args.console_log_path) # Use the default formatter that is a no-op formatter. - setup_logger(LOG.xcuitest_test_output, - logfile=args.test_output_path, + setup_logger(LOG.xcuitest_console_log, + logfile=args.console_log_path, disableStderrLogger=True, # Disable console logging. level=log_level, formatter=logging.Formatter()) @@ -879,9 +879,9 @@ def cmd_test(args: argparse.Namespace): help="set command line args to target app with a comma-separated list of strings"), dict(args=['--tests-to-run'], help="specify a set of test classes or test methods to run, format: a comma-separated list of Test-Class-Name[/Test-Method-Name]"), - dict(args=['--test_process_log_path'], + dict(args=['--process-log-path'], help='The file path to store XCUITest test process logs. By default they are not stored to a file.'), - dict(args=['--test_output_path'], + dict(args=['--console-log-path'], help='The file path to store XCUITest test output, e.g. UI activity summaries. By default they are not stored to a file.'), ], help="run XCTest (XCUITest)"), diff --git a/tidevice/_device.py b/tidevice/_device.py index 5fab030..d84f581 100644 --- a/tidevice/_device.py +++ b/tidevice/_device.py @@ -46,8 +46,8 @@ from .session import Session logger = logging.getLogger(__name__) -xctest_test_process_logger = logging.getLogger(LOG.xcuitest_test_process_log) -xctest_test_output_logger = logging.getLogger(LOG.xcuitest_test_output) +xcuitest_process_logger = logging.getLogger(LOG.xcuitest_process_log) +xcuitest_console_logger = logging.getLogger(LOG.xcuitest_console_log) def pil_imread(data: Union[str, pathlib.Path, bytes, bytearray]) -> Image.Image: @@ -944,7 +944,7 @@ def _callback(m: DTXMessage): # XCTestOutputBarrier is just ouput separators, no need to # print them in the logs. if args[0].rstrip() != 'XCTestOutputBarrier': - xctest_test_output_logger.debug('%s', args[0].rstrip()) + xcuitest_console_logger.debug('%s', args[0].rstrip()) # In low iOS versions, 'Using singleton test manager' may not be printed... mark wda launch status = True if server url has been printed if "ServerURLHere" in args[0]: logger.info("%s", args[0].rstrip()) @@ -954,11 +954,11 @@ def _log_message_callback(m: DTXMessage): identifier, args = m.result logger.debug("logConsole: %s", args) if isinstance(args, (tuple, list)): - for msg in args: - msg = msg.rstrip() if isinstance(msg, str) else msg - xctest_test_process_logger.debug('%s', msg) + for msg in args: + msg = msg.rstrip() if isinstance(msg, str) else msg + xcuitest_process_logger.debug('%s', msg) else: - xctest_test_process_logger.debug('%s', args) + xcuitest_process_logger.debug('%s', args) conn.register_callback("_XCT_logDebugMessage:", _log_message_callback) @@ -1075,9 +1075,9 @@ def _show_log_message(m: DTXMessage): if isinstance(m.result[1], (tuple, list)): for msg in m.result[1]: msg = msg.rstrip() if isinstance(msg, str) else msg - xctest_test_process_logger.debug('%s', msg) + xcuitest_process_logger.debug('%s', msg) else: - xctest_test_process_logger.debug('%s', m.result[1]) + xcuitest_process_logger.debug('%s', m.result[1]) test_results = [] test_results_lock = threading.Lock() diff --git a/tidevice/_proto.py b/tidevice/_proto.py index 6372789..925434b 100644 --- a/tidevice/_proto.py +++ b/tidevice/_proto.py @@ -17,8 +17,8 @@ class LOG(str, enum.Enum): root = "tidevice" xcuitest = "tidevice.xctest" - xcuitest_test_process_log = "tidevice.xctest.test_process_log" - xcuitest_test_output = "tidevice.xctest.test_output" + xcuitest_process_log = "tidevice.xctest.test_process_log" + xcuitest_console_log = "tidevice.xctest.test_console_log" socket = "tidevice.socket"