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
+43-10Lines changed: 43 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Pyoslog
2
-
Pyoslog is a simple Python module that allows you to send messages to the macOS [unified logging system](https://developer.apple.com/documentation/os/os_log).
2
+
Pyoslog allows you to send messages to the macOS [unified logging system](https://developer.apple.com/documentation/os/os_log) using Python.
3
3
4
4
```python
5
5
from pyoslog import os_log, OS_LOG_DEFAULT
@@ -8,27 +8,37 @@ os_log(OS_LOG_DEFAULT, 'Hello from Python!')
8
8
9
9
10
10
## Installation
11
-
Pyoslog requires macOS 10.12 or later.
11
+
Pyoslog requires macOS 10.12 or later and Python 3.6 or later.
12
12
Install using `pip`:
13
13
14
14
```shell
15
15
python -m pip install pyoslog
16
16
```
17
17
18
-
The module will install and import without error on earlier macOS versions (and on unsupported Operating Systems and Python versions).
19
-
Use `pyoslog.is_supported()` if you need to support old macOS versions or other environments and want to know at runtime whether to use pyoslog.
18
+
The module will install and import without error on earlier macOS versions, or on unsupported Operating Systems or incompatible Python versions.
19
+
Use `pyoslog.is_supported()` if you need to support incompatible environments and want to know at runtime whether to use pyoslog.
20
20
Please note that if `is_supported()` returns `False` then none of the module's other methods or constants will exist.
21
21
22
22
23
23
## Usage
24
-
Pyoslog currently provides the methods [`os_log_create`](https://developer.apple.com/documentation/os/1643744-os_log_create), [`os_log_with_type`](https://developer.apple.com/documentation/os/os_log_with_type) and [`os_log`](https://developer.apple.com/documentation/os/os_log), each with the same signatures as their native versions.
It is not possible to directly set a log object's mode from Python, but see the `config` section of `man log` for documentation about doing this in `sudo` mode.
70
+
41
71
### Integration with the logging module
42
72
Use the pyoslog `Handler` to direct messages to pyoslog:
43
73
@@ -59,14 +89,14 @@ Logs can be viewed using Console.app or the `log` command.
59
89
For example, messages sent using the default configuration can be streamed using:
See `man log` for further details about the available options and filters.
@@ -84,11 +114,14 @@ After installing the OSLog wrappers (via `python -m pip install pyobjc-framework
84
114
python -m unittest
85
115
```
86
116
117
+
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.
119
+
87
120
88
121
## Alternatives
89
122
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).
90
123
Since then, the [macos-oslog](https://pypi.org/project/macos-oslog/) module has been released, with broadly equivalent functionality to pyoslog.
91
-
There are also other options available if PyPi access is not seen as a constraint:
124
+
In addition, there are other options available if PyPi access is not seen as a constraint:
0 commit comments