mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
[3.13] gh-129248: Filter out the iOS log prefix from testbed runner output. (GH-129252) (#129283)
Filter out the iOS log prefix from testbed runner output.
(cherry picked from commit a58083811a
)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
This commit is contained in:
parent
104bcff983
commit
aa1beed858
2 changed files with 17 additions and 0 deletions
|
@ -2,6 +2,7 @@ import argparse
|
|||
import asyncio
|
||||
import json
|
||||
import plistlib
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -12,6 +13,18 @@ from pathlib import Path
|
|||
|
||||
DECODE_ARGS = ("UTF-8", "backslashreplace")
|
||||
|
||||
# The system log prefixes each line:
|
||||
# 2025-01-17 16:14:29.090 Df iOSTestbed[23987:1fd393b4] (Python) ...
|
||||
# 2025-01-17 16:14:29.090 E iOSTestbed[23987:1fd393b4] (Python) ...
|
||||
|
||||
LOG_PREFIX_REGEX = re.compile(
|
||||
r"^\d{4}-\d{2}-\d{2}" # YYYY-MM-DD
|
||||
r"\s+\d+:\d{2}:\d{2}\.\d+" # HH:MM:SS.sss
|
||||
r"\s+\w+" # Df/E
|
||||
r"\s+iOSTestbed\[\d+:\w+\]" # Process/thread ID
|
||||
r"\s+\(Python\)\s" # Logger name
|
||||
)
|
||||
|
||||
|
||||
# Work around a bug involving sys.exit and TaskGroups
|
||||
# (https://github.com/python/cpython/issues/101515).
|
||||
|
@ -131,6 +144,8 @@ async def log_stream_task(initial_devices):
|
|||
) as process:
|
||||
suppress_dupes = False
|
||||
while line := (await process.stdout.readline()).decode(*DECODE_ARGS):
|
||||
# Strip the prefix from each log line
|
||||
line = LOG_PREFIX_REGEX.sub("", line)
|
||||
# The iOS log streamer can sometimes lag; when it does, it outputs
|
||||
# a warning about messages being dropped... often multiple times.
|
||||
# Only print the first of these duplicated warnings.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue