# ot-logging-helpers
This python package provides logging helpers that are used in Orthanc Team projects.
## Demo
```python
from ot_logging_helpers import LogContext, configure_logging
import logging
import threading
configure_logging()
with LogContext("1ST"):
logging.info("my first message")
with LogContext("2ND"):
logging.info("my second message")
def worker(worker_id):
with LogContext(f"Worker {worker_id}"):
logging.info("my top level worker message")
with LogContext("next-context"):
logging.warning("my warning")
for i in range(0, 2):
thread = threading.Thread(target=worker, args=(i+1, ))
thread.start()
###### this shall output
# 2024-04-05 15:05:28,162 - root - INFO - 1ST | my first message
# 2024-04-05 15:05:28,162 - root - INFO - 1ST | 2ND | my second message
# 2024-04-05 15:05:28,163 - root - INFO - Worker 1 | my top level worker message
# 2024-04-05 15:05:28,163 - root - WARNING - Worker 1 | next-context | my warning
# 2024-04-05 15:05:28,163 - root - INFO - Worker 2 | my top level worker message
# 2024-04-05 15:05:28,163 - root - WARNING - Worker 2 | next-context | my warning
```
Raw data
{
"_id": null,
"home_page": "https://github.com/orthanc-team/ot-logging-helpers",
"name": "ot-logging-helpers",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.8",
"maintainer_email": null,
"keywords": "logging",
"author": "Orthanc Team",
"author_email": "info@orthanc.team",
"download_url": "https://files.pythonhosted.org/packages/1f/2d/6b6472c294db4433cae65f587d9d98f985159e811b2734ac1b0e45de434d/ot_logging_helpers-0.1.1.tar.gz",
"platform": null,
"description": "# ot-logging-helpers\n\nThis python package provides logging helpers that are used in Orthanc Team projects.\n\n## Demo\n\n```python\nfrom ot_logging_helpers import LogContext, configure_logging\nimport logging\nimport threading\n\nconfigure_logging()\n\nwith LogContext(\"1ST\"):\n logging.info(\"my first message\")\n with LogContext(\"2ND\"):\n logging.info(\"my second message\")\n\n\ndef worker(worker_id):\n with LogContext(f\"Worker {worker_id}\"):\n logging.info(\"my top level worker message\")\n\n with LogContext(\"next-context\"):\n logging.warning(\"my warning\")\n\nfor i in range(0, 2):\n thread = threading.Thread(target=worker, args=(i+1, ))\n thread.start()\n\n\n###### this shall output \n# 2024-04-05 15:05:28,162 - root - INFO - 1ST | my first message\n# 2024-04-05 15:05:28,162 - root - INFO - 1ST | 2ND | my second message\n# 2024-04-05 15:05:28,163 - root - INFO - Worker 1 | my top level worker message\n# 2024-04-05 15:05:28,163 - root - WARNING - Worker 1 | next-context | my warning\n# 2024-04-05 15:05:28,163 - root - INFO - Worker 2 | my top level worker message\n# 2024-04-05 15:05:28,163 - root - WARNING - Worker 2 | next-context | my warning\n\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Python Logging Helpers",
"version": "0.1.1",
"project_urls": {
"Bug Reports": "https://github.com/orthanc-team/ot-logging-helpers/issues",
"Funding": "https://orthanc-team",
"Homepage": "https://github.com/orthanc-team/ot-logging-helpers",
"Source": "https://github.com/orthanc-team/ot-logging-helpers/"
},
"split_keywords": [
"logging"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ad93734395e0dff882f859c0d71b0a5cbb4392b76c0a58bdffa751bebd57eb1f",
"md5": "cf30540ec57fbc5b40b5e1d10baa6503",
"sha256": "e9129a18427a1fd14a1b98e6b10594a70d3bc647f0fa45314394b3f1d4e6f9e6"
},
"downloads": -1,
"filename": "ot_logging_helpers-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cf30540ec57fbc5b40b5e1d10baa6503",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.8",
"size": 3723,
"upload_time": "2024-04-05T14:44:41",
"upload_time_iso_8601": "2024-04-05T14:44:41.569991Z",
"url": "https://files.pythonhosted.org/packages/ad/93/734395e0dff882f859c0d71b0a5cbb4392b76c0a58bdffa751bebd57eb1f/ot_logging_helpers-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1f2d6b6472c294db4433cae65f587d9d98f985159e811b2734ac1b0e45de434d",
"md5": "b928026cb4f18d7797b7c269b2a36fc7",
"sha256": "5aa72c09528500c4f6fc954fea4e08ebce345d6a4f6e86f9ab55883a5b6da8a2"
},
"downloads": -1,
"filename": "ot_logging_helpers-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "b928026cb4f18d7797b7c269b2a36fc7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.8",
"size": 5298,
"upload_time": "2024-04-05T14:44:43",
"upload_time_iso_8601": "2024-04-05T14:44:43.118297Z",
"url": "https://files.pythonhosted.org/packages/1f/2d/6b6472c294db4433cae65f587d9d98f985159e811b2734ac1b0e45de434d/ot_logging_helpers-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-05 14:44:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "orthanc-team",
"github_project": "ot-logging-helpers",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ot-logging-helpers"
}