You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,21 +106,29 @@ When labelling subsystem and category using the native C methods there is a requ
106
106
The pyoslog module handles this for you – there is no need to `del` or release these objects.
107
107
108
108
109
+
## Limitations
110
+
As noted above, while the macOS `os_log` API allows use of a format string with many methods, this name is required to be a C string literal.
111
+
As a result, pyoslog hardcodes all format strings to `"%{public}s"`.
112
+
113
+
109
114
## Testing
110
-
The pyoslog module's tests require the [pyobjc OSLog framework wrappers](https://pypi.org/project/pyobjc-framework-OSLog/) in order to verify output and, as a result, can only be run on macOS 10.15 or later.
115
+
The pyoslog module's tests require the [pyobjc OSLog framework wrappers](https://pypi.org/project/pyobjc-framework-OSLog/) and the [storeWithScope initialiser](https://developer.apple.com/documentation/oslog/oslogstore/3548057-storewithscope) in order to verify output so, as a result, can only be run on macOS 12 or later.
116
+
111
117
After installing the OSLog wrappers (via `python -m pip install pyobjc-framework-OSLog`), navigate to the [tests](https://github.com/simonrob/pyoslog/tree/main/tests) directory and run:
112
118
113
119
```shell
114
120
python -m unittest
115
121
```
116
122
117
123
Please note that if Console.app is live-streaming messages, some tests may fail.
118
-
See [`test_logging.py`](https://github.com/simonrob/pyoslog/blob/main/tests/test_logging.py#L84) for discussion about why this is the case.
124
+
See [`test_logging.py`](https://github.com/simonrob/pyoslog/blob/main/tests/test_logging.py#L93) for discussion about why this is the case.
119
125
120
126
121
127
## Alternatives
122
128
At the time this module was created there were no alternatives available on [PyPi](https://pypi.org/search/?q=macos+unified+logging&c=Operating+System+%3A%3A+MacOS).
123
-
Since then, the [macos-oslog](https://pypi.org/project/macos-oslog/) module has been released, with broadly equivalent functionality to pyoslog.
129
+
Since then, the [macos-oslog](https://pypi.org/project/macos-oslog/) module has been released, with broadly equivalent functionality to pyoslog, except for the need to manually release the log object.
130
+
There is also [os-signpost](https://pypi.org/project/os-signpost/), which uses `cython` to provide the [`OSSignposter`](https://developer.apple.com/documentation/os/ossignposter) API, and could easily be extended to provide `os_log` functionality.
131
+
124
132
In addition, there are other options available if PyPi access is not seen as a constraint:
Copy file name to clipboardExpand all lines: build.sh
+24-12Lines changed: 24 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -1,38 +1,50 @@
1
+
# this build script is quite forceful about setup - make sure not to mess up the system python
2
+
PYTHON_VENV=$(python -c "import sys; sys.stdout.write('1') if hasattr(sys, 'real_prefix') or sys.base_prefix != sys.prefix else sys.stdout.write('0')")
3
+
if [ "$PYTHON_VENV"== 0 ];then
4
+
echo'Warning: not running in a Python virtual environment. Please either activate a venv or edit the script to confirm this action'
5
+
exit 1
6
+
fi
7
+
1
8
module=${PWD##*/}# get module name - relies on directory name == module name
2
9
module=${module:-/}
3
10
4
-
echo"Preparing environment for $module"
5
-
python -m pip install twine # we don't have a requirements.txt so easiest just to be sure twine exists every time
11
+
printf"\nPreparing environment for %s…\n""$module"
12
+
python -m pip install --quiet --upgrade pip
13
+
python -m pip install --quiet setuptools wheel twine mypy sphinx # we don't have a requirements.txt, so easiest just to be sure build dependencies exist every time
if [ -z"$1" ];then# exit unless a parameter is provided (we use 'deploy' but don't actually care what it is)
26
-
printf'\nExiting build script - run "./build.sh deploy" to also upload to PyPi / Read the Docs\n'
27
-
exit1
38
+
printf'\nExiting build script - run "./build.sh deploy" to also upload to PyPi / Read the Docs (please git commit first)\n\n'
39
+
exit0
28
40
fi
29
41
30
42
printf"\nUpload the $(tput bold)%s$(tput sgr0) package to the \033[0;32m$(tput bold)Test PyPI repository$(tput sgr0)\033[0m via Twine? (y to confirm; n to skip; any other key to exit): ""$module"
31
43
read -r answer
32
44
33
45
if [ "$answer"!="${answer#[Yy]}" ];then
34
46
PYPI_TEST_TOKEN=$(<versions/pypi-test.token)
35
-
if twine upload -u __token__ -p "$PYPI_TEST_TOKEN" --repository testpypi dist/*;then
0 commit comments