logging-journald
================
[![PyPI - License](https://img.shields.io/pypi/l/logging-journald)](https://pypi.org/project/logging-journald) [![Wheel](https://img.shields.io/pypi/wheel/logging-journald)](https://pypi.org/project/logging-journald) [![PyPI](https://img.shields.io/pypi/v/logging-journald)](https://pypi.org/project/logging-journald) [![PyPI](https://img.shields.io/pypi/pyversions/logging-journald)](https://pypi.org/project/logging-journald) [![Coverage Status](https://coveralls.io/repos/github/mosquito/logging-journald/badge.svg?branch=master)](https://coveralls.io/github/mosquito/logging-journald?branch=master) ![tests](https://github.com/mosquito/logging-journald/workflows/tests/badge.svg?branch=master)
Pure python logging handler for writing logs to the journald using
native protocol.
```python
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](https://www.freedesktop.org/wiki/Software/systemd/catalog/):
> 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.
```python
from logging_journald import JournaldLogHandler
...
handler = JournaldLogHandler(use_message_id=False)
...
```
Raw data
{
"_id": null,
"home_page": "https://github.com/mosquito/logging-journald",
"name": "logging-journald",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Dmitry Orlov",
"author_email": "me@mosquito.su",
"download_url": "https://files.pythonhosted.org/packages/cc/07/77567e0001d3acffddc80470497f0eec3ccb544b72e672550b3c1f02e586/logging_journald-0.6.11.tar.gz",
"platform": null,
"description": "logging-journald\n================\n\n[![PyPI - License](https://img.shields.io/pypi/l/logging-journald)](https://pypi.org/project/logging-journald) [![Wheel](https://img.shields.io/pypi/wheel/logging-journald)](https://pypi.org/project/logging-journald) [![PyPI](https://img.shields.io/pypi/v/logging-journald)](https://pypi.org/project/logging-journald) [![PyPI](https://img.shields.io/pypi/pyversions/logging-journald)](https://pypi.org/project/logging-journald) [![Coverage Status](https://coveralls.io/repos/github/mosquito/logging-journald/badge.svg?branch=master)](https://coveralls.io/github/mosquito/logging-journald?branch=master) ![tests](https://github.com/mosquito/logging-journald/workflows/tests/badge.svg?branch=master)\n\nPure python logging handler for writing logs to the journald using\nnative protocol.\n\n```python\nimport logging\nfrom logging_journald import JournaldLogHandler, check_journal_stream\n\n# Use python default handler\nLOG_HANDLERS = None\n\n\nif (\n # Check if program running as systemd service\n check_journal_stream() or\n # Check if journald socket is available\n JournaldLogHandler.SOCKET_PATH.exists()\n):\n LOG_HANDLERS = [JournaldLogHandler()]\n\nlogging.basicConfig(level=logging.INFO, handlers=LOG_HANDLERS)\nlogging.info(\"Hello logging world.\")\n```\n\n`MESSAGE_ID` field\n------------------\n\nAs defined in [catalog documentation](https://www.freedesktop.org/wiki/Software/systemd/catalog/):\n\n> A `128-bit` message identifier ID for recognizing certain message types, if this is desirable. This should contain a\n128-bit ID formatted as a lower-case hexadecimal string, without any separating dashes or suchlike. This is recommended\nto be a UUID-compatible ID, but this is not enforced, and formatted differently. Developers can generate a new ID for\nthis purpose with systemd-id128 new.\n\nSo you're free to choose how you want to act. By default, `MESSAGE_ID` is generated as a hash of the message and some\nstatic fields. But you can disable this by passing `use_message_id=False` to the class constructor.\n\n\n```python\nfrom logging_journald import JournaldLogHandler\n\n...\n\nhandler = JournaldLogHandler(use_message_id=False)\n\n...\n```",
"bugtrack_url": null,
"license": "MIT",
"summary": "Pure python logging handler for writing logs to the journald using native protocol",
"version": "0.6.11",
"project_urls": {
"Homepage": "https://github.com/mosquito/logging-journald",
"Source": "https://github.com/mosquito/logging-journald",
"Tracker": "https://github.com/mosquito/logging-journald/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "277b033a15aea43108af5049d8c0a09c3ea30519295aee1f3ed74c9efa1ee4cb",
"md5": "18b88a5b0bae27af04e7ccb197c17dfa",
"sha256": "4d280eb0bddb4bf616297ee2428592b037618b6f0169c873f655aff92496c232"
},
"downloads": -1,
"filename": "logging_journald-0.6.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "18b88a5b0bae27af04e7ccb197c17dfa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 5619,
"upload_time": "2024-12-13T08:17:09",
"upload_time_iso_8601": "2024-12-13T08:17:09.127993Z",
"url": "https://files.pythonhosted.org/packages/27/7b/033a15aea43108af5049d8c0a09c3ea30519295aee1f3ed74c9efa1ee4cb/logging_journald-0.6.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cc0777567e0001d3acffddc80470497f0eec3ccb544b72e672550b3c1f02e586",
"md5": "674cf5b49a7b0804008c743032a3b4a5",
"sha256": "1741ae42cf8953e435489a82acf0e88bc21ad23351e867ca4453a354fc6d09e1"
},
"downloads": -1,
"filename": "logging_journald-0.6.11.tar.gz",
"has_sig": false,
"md5_digest": "674cf5b49a7b0804008c743032a3b4a5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 5432,
"upload_time": "2024-12-13T08:17:10",
"upload_time_iso_8601": "2024-12-13T08:17:10.147285Z",
"url": "https://files.pythonhosted.org/packages/cc/07/77567e0001d3acffddc80470497f0eec3ccb544b72e672550b3c1f02e586/logging_journald-0.6.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-13 08:17:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mosquito",
"github_project": "logging-journald",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "logging-journald"
}