Skip to content

Commit

Permalink
update console arg name and indent code
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Nov 28, 2023
1 parent 3073192 commit 46ec1a7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
20 changes: 10 additions & 10 deletions tidevice/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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)"),
Expand Down
18 changes: 9 additions & 9 deletions tidevice/_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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())
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tidevice/_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down

0 comments on commit 46ec1a7

Please sign in to comment.