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/d1/b8/c7a0de68c9083862802770695affede953acef501a8809df4fbf83c2551a/logging_journald-0.6.9.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.9",
"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": "715a9f646db32e009d3a866d64f89c636ee8c22fd104cf923540dc35ecac961d",
"md5": "d565b5b9be5ee56f960d536d1715319f",
"sha256": "c3078b5db5e3e94a75fbf624d3255b3dfbf0bcbde7f36bad77271a7422acd0b0"
},
"downloads": -1,
"filename": "logging_journald-0.6.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d565b5b9be5ee56f960d536d1715319f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 5613,
"upload_time": "2024-08-09T14:04:33",
"upload_time_iso_8601": "2024-08-09T14:04:33.622265Z",
"url": "https://files.pythonhosted.org/packages/71/5a/9f646db32e009d3a866d64f89c636ee8c22fd104cf923540dc35ecac961d/logging_journald-0.6.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d1b8c7a0de68c9083862802770695affede953acef501a8809df4fbf83c2551a",
"md5": "f845951fd4e0194f7568b210c5f53b24",
"sha256": "f4b242de387e24509e8dd490eac7980f98e2f82b259581d2c5936e1b477ec126"
},
"downloads": -1,
"filename": "logging_journald-0.6.9.tar.gz",
"has_sig": false,
"md5_digest": "f845951fd4e0194f7568b210c5f53b24",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 5432,
"upload_time": "2024-08-09T14:04:35",
"upload_time_iso_8601": "2024-08-09T14:04:35.324054Z",
"url": "https://files.pythonhosted.org/packages/d1/b8/c7a0de68c9083862802770695affede953acef501a8809df4fbf83c2551a/logging_journald-0.6.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-09 14:04:35",
"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"
}