Skip to main content

logging-journald

PyPI - License Wheel PyPI PyPI Coverage Status tests

Pure python logging handler for writing logs to the journald using native protocol.

import logging
from logging_journald import JournaldLogHandler, check_journal_stream

# Use python default handler
LOG_HANDLERS = None


if (
    # Check if program running as systemd service
    check_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.")

MESSAGE_ID field

As defined in catalog documentation:

A 128-bit message identifier ID for recognizing certain message types, if this is desirable. This should contain a 128-bit ID formatted as a lower-case hexadecimal string, without any separating dashes or suchlike. This is recommended to be a UUID-compatible ID, but this is not enforced, and formatted differently. Developers can generate a new ID for this purpose with systemd-id128 new.

So you're free to choose how you want to act. By default, MESSAGE_ID is generated as a hash of the message and some static fields. But you can disable this by passing use_message_id=False to the class constructor.

from logging_journald import JournaldLogHandler

...

handler = JournaldLogHandler(use_message_id=False)

...

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.12.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logging_journald-0.6.12-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file logging_journald-0.6.12.tar.gz.

File metadata

  • Download URL: logging_journald-0.6.12.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for logging_journald-0.6.12.tar.gz
Algorithm Hash digest
SHA256 d6bd338460b5ecd88f6b3e9a6499a6994c65d5d8296f3aa4830b25a7d7e815a9
MD5 056c56c71d5af3b37f2b1e92fbeb3616
BLAKE2b-256 71dfc013c3d8f37a351ceb35f166bc9a0a69365655ab13eb4366032e96c6da33

See more details on using hashes here.

Provenance

The following attestation bundles were made for logging_journald-0.6.12.tar.gz:

Publisher: publish.yml on mosquito/logging-journald

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file logging_journald-0.6.12-py3-none-any.whl.

File metadata

File hashes

Hashes for logging_journald-0.6.12-py3-none-any.whl
Algorithm Hash digest
SHA256 b94d1c7082d7a7ddc69f8fc1a6cf420da3d97a03363c12659859fec09f44f811
MD5 fa21d47603a59267e5d9cdcf6441b262
BLAKE2b-256 24f32b2033e02f6a08eaefed14351056b797f780c7f5aaa6765e66d734fac91b

See more details on using hashes here.

Provenance

The following attestation bundles were made for logging_journald-0.6.12-py3-none-any.whl:

Publisher: publish.yml on mosquito/logging-journald

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.6.12 This release

2 files

0.6.11

2 files

0.6.10

2 files

0.6.9

2 files

0.6.8

2 files

0.6.7

2 files

0.6.6

2 files

0.6.5

2 files

0.6.4

2 files

0.6.3

2 files

0.6.2

1 file

0.6.1

1 file

0.6.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page