Skip to content

Commit 1bc24c8

Browse files
authored
Switch logging to use os_log (#96)
1 parent b87bd4f commit 1bc24c8

18 files changed

Lines changed: 658 additions & 156 deletions

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ updates:
1212
directory: "/"
1313
patterns: ["*"]
1414
multi-ecosystem-group: "dependencies"
15+
cooldown:
16+
default-days: 7
1517

1618
- package-ecosystem: "pip"
1719
directory: "/"
1820
patterns: ["*"]
1921
multi-ecosystem-group: "dependencies"
22+
cooldown:
23+
default-days: 7
2024

2125
- package-ecosystem: "pre-commit"
2226
directory: "/"
2327
patterns: ["*"]
2428
multi-ecosystem-group: "dependencies"
29+
cooldown:
30+
default-days: 7

.github/workflows/check-pr-template.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ on:
44
pull_request:
55
types: [opened, edited, reopened, synchronize]
66

7+
permissions: {}
8+
79
jobs:
810
check-pr-template:
911
name: Check PR template
10-
uses: beeware/.github/.github/workflows/pr-checklist.yml@main
12+
permissions:
13+
pull-requests: read
14+
uses: beeware/.github/.github/workflows/pr-checklist.yml@66283ddb9e206f93b423118deecf1caf516078c1 # main

.github/workflows/ci.yml

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ on:
44
push:
55
branches:
66
- main
7+
tags:
8+
- "v*"
9+
workflow_call:
10+
inputs:
11+
attest-package:
12+
description: "Create GitHub provenance attestation for the package."
13+
default: "false"
14+
type: string
715

816
# Cancel active CI runs for a PR before starting another run
917
concurrency:
@@ -14,12 +22,128 @@ defaults:
1422
run:
1523
shell: bash
1624

25+
# Default to no permissions; each job opts in to exactly what it needs.
26+
permissions: {}
27+
1728
env:
1829
FORCE_COLOR: "1"
1930

2031
jobs:
2132
pre-commit:
2233
name: Pre-commit checks
23-
uses: beeware/.github/.github/workflows/pre-commit-run.yml@main
34+
permissions:
35+
contents: read
36+
uses: beeware/.github/.github/workflows/pre-commit-run.yml@66283ddb9e206f93b423118deecf1caf516078c1 # main
2437
with:
2538
pre-commit-source: "pre-commit"
39+
40+
build-wheels:
41+
needs: pre-commit
42+
name: Build wheels
43+
runs-on: macos-latest
44+
permissions:
45+
id-token: write
46+
attestations: write
47+
contents: read
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
51+
with:
52+
fetch-depth: 0
53+
persist-credentials: false
54+
55+
- name: Set up Python
56+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
57+
with:
58+
python-version: "3.x"
59+
60+
- name: Build wheels
61+
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
62+
with:
63+
output-dir: dist
64+
65+
- name: Generate build provenance attestation for wheels
66+
if: inputs.attest-package == 'true'
67+
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4
68+
with:
69+
subject-path: "dist/*.whl"
70+
71+
- name: Upload artefacts
72+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
73+
with:
74+
name: dist-wheels
75+
path: ./dist/*.whl
76+
if-no-files-found: error
77+
78+
build-sdist:
79+
needs: pre-commit
80+
name: Build sdist
81+
runs-on: macos-latest
82+
permissions:
83+
id-token: write
84+
attestations: write
85+
contents: read
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
89+
with:
90+
fetch-depth: 0
91+
persist-credentials: false
92+
93+
- name: Set up Python
94+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
95+
with:
96+
python-version: "3.x"
97+
98+
- name: Build sdist
99+
run: |
100+
python -m pip install --upgrade build
101+
python -m build --sdist
102+
103+
- name: Generate build provenance attestation for sdist
104+
if: inputs.attest-package == 'true'
105+
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4
106+
with:
107+
subject-path: "dist/*.tar.gz"
108+
109+
- name: Upload artefacts
110+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
111+
with:
112+
name: dist-sdist
113+
path: ./dist/*.tar.gz
114+
if-no-files-found: error
115+
116+
test:
117+
name: Test (${{ matrix.python-version }})
118+
needs: build-wheels
119+
runs-on: macos-latest
120+
permissions:
121+
contents: read
122+
strategy:
123+
fail-fast: false
124+
matrix:
125+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
126+
steps:
127+
- name: Checkout
128+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
129+
with:
130+
fetch-depth: 0
131+
persist-credentials: false
132+
133+
- name: Set up Python
134+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
135+
with:
136+
python-version: ${{ matrix.python-version }}
137+
allow-prereleases: true
138+
139+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
140+
with:
141+
name: dist-wheels
142+
path: wheelhouse
143+
144+
- name: Install tox
145+
run: |
146+
python -m pip install --group tox-uv
147+
148+
- name: Run smoke test
149+
run: tox -e py

.github/workflows/new-issue.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ on:
77
- reopened
88
- transferred
99

10+
permissions: {}
11+
1012
jobs:
1113
add-to-project:
1214
name: Add issue to BeeWare project
1315
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
1418
steps:
15-
- uses: actions/add-to-project@v2.0.0
19+
- uses: actions/add-to-project@5afcf98fcd03f1c2f92c3c83f58ae24323cc57fd # v2.0.0
1620
with:
1721
project-url: https://github.com/orgs/beeware/projects/1
1822
github-token: ${{ secrets.BRUTUS_PAT_TOKEN }}

.github/workflows/publish.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Upload Python Package
2+
3+
on:
4+
release:
5+
types: published
6+
7+
permissions: {}
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
# This permission is required for trusted publishing.
14+
id-token: write
15+
steps:
16+
- uses: dsaltares/fetch-gh-release-asset@aa2ab1243d6e0d5b405b973c89fa4d06a2d0fff7 # 1.1.2
17+
with:
18+
version: tags/${{ github.event.release.tag_name }}
19+
# This next line is *not* a bash filename expansion - it's a regex.
20+
# We need to match all files that start with std-nslog or
21+
# std_nslog, but not the "Source code" zip and tarball.
22+
file: std.*
23+
regex: true
24+
target: dist/
25+
26+
- name: Publish release to production PyPI
27+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1

.github/workflows/release.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions: {}
9+
10+
jobs:
11+
ci:
12+
name: CI
13+
permissions:
14+
contents: read
15+
id-token: write
16+
attestations: write
17+
uses: ./.github/workflows/ci.yml
18+
with:
19+
attest-package: "true"
20+
21+
release:
22+
name: Create Release
23+
needs: [ci, docs]
24+
# This has to be run on macOS, because rubicon tries to load the Foundation library
25+
runs-on: macOS-latest
26+
permissions:
27+
contents: write
28+
steps:
29+
- name: Set build variables
30+
run: |
31+
echo "VERSION=${GITHUB_REF_NAME#v}" | tee -a $GITHUB_ENV
32+
33+
- name: Get packages
34+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
35+
with:
36+
name: dist-*
37+
merge-multiple: true
38+
path: dist
39+
40+
- name: Create Release
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
GH_REPO: ${{ github.repository }}
44+
shell: bash
45+
run: gh release create "$GITHUB_REF_NAME" --draft --title "$VERSION" dist/*
46+
47+
test-publish:
48+
name: Publish test package
49+
needs: [ci, docs, release]
50+
runs-on: ubuntu-latest
51+
permissions:
52+
contents: write
53+
# This permission is required for trusted publishing.
54+
id-token: write
55+
steps:
56+
- name: Get packages
57+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
58+
with:
59+
name: ${{ needs.ci.outputs.artifact-name }}
60+
path: dist
61+
62+
- name: Publish release to Test PyPI
63+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
64+
with:
65+
repository-url: https://test.pypi.org/legacy/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ lib64/
2020
parts/
2121
sdist/
2222
var/
23+
wheelhouse/
2324
*.egg-info/
2425
.installed.cfg
2526
*.egg

.pre-commit-config.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,13 @@ repos:
1212
rev: v0.15.13
1313
hooks:
1414
- id: ruff-check
15-
args: [ --fix ]
15+
args: [--fix]
1616
- id: ruff-format
17+
- repo: https://github.com/rvben/rumdl-pre-commit
18+
rev: v0.1.87
19+
hooks:
20+
- id: rumdl
21+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
22+
rev: v1.25.2
23+
hooks:
24+
- id: zizmor

CHANGELOG.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
# Changelog
22

3+
## 2.0.0 (In development)
4+
5+
* The shim now writes to Apple's unified logging system (`os_log`) instead
6+
of the deprecated `NSLog` API. Output written to `stdout` and `stderr`
7+
appears in Console.app and `log stream` as before, but is now tagged with
8+
the `OS_LOG_TYPE_DEFAULT` and `OS_LOG_TYPE_ERROR` levels respectively,
9+
so the two streams can be filtered separately.
10+
* The `STD_NSLOG_SUBSYSTEM` and `STD_NSLOG_CATEGORY` environment variables
11+
can be used to associate log output with a specific subsystem and category
12+
for `log` predicate filtering. If unset, `OS_LOG_DEFAULT` is used,
13+
preserving the legacy behavior.
14+
* The package now ships a native extension module (`_oslog_shim`) and is
15+
therefore distributed as platform-specific wheels for macOS and iOS rather
16+
than a pure-Python wheel.
17+
* The `encoding` attribute on the writer is now `"utf-8"` (previously `"utf-16-le"` / `"utf-16-be"`), reflecting the underlying API.
18+
319
## 1.0.3 (November 25 2022)
420

5-
* Ensure that user-provided strings are escaped when output to the log. This
6-
could cause segfaults if the user-provided string contained `"%s"` (or other
7-
C-style formatting placeholders).
21+
* Ensure that user-provided strings are escaped when output to the log. This could cause segfaults if the user-provided string contained `"%s"` (or other C-style formatting placeholders).
822

923
## 1.0.2 (November 17 2022)
1024

11-
* Corrected a bug where printing a blank line would cause the previous line
12-
to be duplicated in the log.
25+
* Corrected a bug where printing a blank line would cause the previous line to be duplicated in the log.
1326

1427
## 1.0.1 (April 7 2022)
1528

16-
* Removed the exception handling shim; this can now be handled by the iOS and
17-
macOS stub apps.
29+
* Removed the exception handling shim; this can now be handled by the iOS and macOS stub apps.
1830

1931
## 1.0.0 (Feb 28 2022)
2032

MANIFEST.in

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)