Pure python logging handler for writing logs to the journald using native protocol
Project description
Pure python logging handler for writing logs to the journald using native protocol.
import logging
from logging_journald import JournaldLogHandler
# Use python default handler
LOG_HANDLERS = None
if (
# Check if program running as systemd service
JournaldLogHandler.JOURNAL_STREAM or
# Check if journald socket is available
JournaldLogHandler.SOCKET_PATH.exists()
):
LOG_HANDLERS = [JournaldLogHandler()]
logging.basicConfig(level=logging.INFO, handlers=LOG_HANDLERS)
logging.info("Hello logging world.")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
logging-journald-0.6.0.tar.gz
(4.0 kB
view hashes)