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
+44-7Lines changed: 44 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,21 @@ from pyoslog import os_log, OS_LOG_DEFAULT
6
6
os_log(OS_LOG_DEFAULT, 'Hello from Python!')
7
7
```
8
8
9
+
9
10
## Installation
10
-
`python -m pip install pyoslog`
11
+
```shell
12
+
python -m pip install pyoslog
13
+
```
14
+
15
+
Pyoslog requires macOS 10.12 or later.
11
16
12
17
13
18
## Usage
14
-
Pyoslog currently provides the methods [`os_log_create`](https://developer.apple.com/documentation/os/1643744-os_log_create), [`os_log_wih_type`](https://developer.apple.com/documentation/os/os_log_with_type) and [`os_log`](https://developer.apple.com/documentation/os/os_log) with the same signatures as their native versions.
19
+
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.
15
20
16
-
The module also offers a helper method, `log` that by default posts a message of type `OS_LOG_TYPE_DEFAULT` to `OS_LOG_DEFAULT`. For example, the shortcut `pyoslog.log('message')` is equivalent to `pyoslog.os_log_with_type(pyoslog.OS_LOG_DEFAULT, pyoslog.OS_LOG_TYPE_DEFAULT, 'message')`.
21
+
The module also offers a helper method – `log`– that by default posts a message of type `OS_LOG_TYPE_DEFAULT` to `OS_LOG_DEFAULT`. For example, the shortcut `log('message')` is equivalent to `os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEFAULT, 'message')`.
17
22
23
+
The `Handler` class is designed for use with Python's inbuilt [logging](https://docs.python.org/3/library/logging.html) module.
18
24
19
25
### Labelling subsystem and category
20
26
Create a log object using `os_log_create` and pass it to any of the log methods to add your own subsystem and category labels:
Messages sent using custom configurations can be filtered more precisely. For example, to receive messages from the labelled subsystem used in the example above:
See `man log` for further details about the available options and filters.
63
+
64
+
65
+
## Alternatives
66
+
At the time this module was created there were no alternatives available on [PyPi](https://pypi.org/). There are, however, other options available if this is not seen as a constraint:
32
67
33
-
Messages sent using custom configurations can be filtered more precisely. For example, to receive messages from the labelled subsystem example above:
Note that the [pyobjc](https://pyobjc.readthedocs.io/) module [OSLog](https://pypi.org/project/pyobjc-framework-OSLog/) is for _reading_ from the unified logging system rather than writing to it. A `log.h` binding is on that project's [roadmap](https://github.com/ronaldoussoren/pyobjc/issues/377), but not yet implemented.
0 commit comments