Send messages to the macOS unified logging system
Reason this release was yanked:
Broken import
Project description
Pyoslog
Pyoslog is a simple extension to send messages to the macOS unified logging system from Python.
from pyoslog import os_log, OS_LOG_DEFAULT
os_log(OS_LOG_DEFAULT, 'Hello from Python!')
Installation
python -m pip install pyoslog
Usage
Pyoslog currently provides the methods os_log_create
, os_log_wih_type
and os_log
with the same signatures as their native versions.
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')
.
Labelling subsystem and category
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:
import pyoslog
log = pyoslog.os_log_create('ac.robinson.pyoslog', 'custom-category')
pyoslog.os_log_with_type(log, pyoslog.OS_LOG_TYPE_DEBUG, 'Message to log object', log, 'of type', pyoslog.OS_LOG_TYPE_DEBUG)
Receiving log messages
Logs can be viewed using Console.app or the log
command. For example, messages sent using the default configuration can be monitored using:
log stream --predicate 'processImagePath CONTAINS "Python"'
Messages sent using custom configurations can be filtered more precisely. For example, to receive messages from the labelled subsystem example above:
log stream --predicate 'subsystem == "ac.robinson.pyoslog"' --level=debug
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyoslog-0.1.0-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a25bddfe6fb6a57e950706a905b7b0481f2ff3b85024d666d77fe7792e314c5 |
|
MD5 | d9934c20fc2f921ea5124461ca20ffd5 |
|
BLAKE2b-256 | b655941976288483c902621facd473db4475a554464949b3bcf66140838dae93 |