Skip to content

Commit

Permalink
Modify macOS log stream filtering to allow for Py3.9 dynamic libffi l…
Browse files Browse the repository at this point in the history
…inking.
  • Loading branch information
freakboy3742 committed Jun 7, 2021
1 parent 1bdd8df commit 9c8495f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
16 changes: 15 additions & 1 deletion src/briefcase/platforms/macOS/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,26 @@ def run_app(self, app: BaseConfig, **kwargs):
print()
print("[{app.app_name}] Following system log output (type CTRL-C to stop log)...".format(app=app))
print("=" * 75)
# Streaming the system log is... a mess. The system log contains a
# *lot* of noise from other processes; even if you filter by
# process, there's a lot of macOS-generated noise. It's very
# difficult to extract just the "user generated" stdout/err log
# messages.
#
# The following sets up a log stream filter that looks for:
# 1. a log sender that matches that app binary; or,
# 2. a log sender of libffi, and a process that matches the app binary.
# Case (1) works for pre-Python 3.9 static linked binaries.
# Case (2) works for Python 3.9+ dynamic linked binaries.
self.subprocess.run(
[
"log",
"stream",
"--style", "compact",
"--predicate", 'senderImagePath=="{sender}"'.format(
"--predicate",
'senderImagePath=="{sender}"'
' OR (processImagePath=="{sender}"'
' AND senderImagePath=="/usr/lib/libffi.dylib")'.format(
sender=str(self.binary_path(app) / "Contents" / "MacOS" / app.formal_name)
)
],
Expand Down
10 changes: 8 additions & 2 deletions tests/platforms/macOS/app/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def test_run_app(first_app_config, tmp_path):
[
'log', 'stream',
'--style', 'compact',
'--predicate', 'senderImagePath=="{bin_path}/Contents/MacOS/First App"'.format(bin_path=bin_path)
'--predicate',
'senderImagePath=="{bin_path}/Contents/MacOS/First App"'
' OR (processImagePath=="{bin_path}/Contents/MacOS/First App"'
' AND senderImagePath=="/usr/lib/libffi.dylib")'.format(bin_path=bin_path)
],
check=True,
)
Expand Down Expand Up @@ -78,7 +81,10 @@ def test_run_app_log_stream_failed(first_app_config, tmp_path):
[
'log', 'stream',
'--style', 'compact',
'--predicate', 'senderImagePath=="{bin_path}/Contents/MacOS/First App"'.format(bin_path=bin_path)
'--predicate',
'senderImagePath=="{bin_path}/Contents/MacOS/First App"'
' OR (processImagePath=="{bin_path}/Contents/MacOS/First App"'
' AND senderImagePath=="/usr/lib/libffi.dylib")'.format(bin_path=bin_path)
],
check=True,
)
Expand Down

0 comments on commit 9c8495f

Please sign in to comment.