kontext


Namekontext JSON
Version 1.2.1 PyPI version JSON
download
home_pagehttps://pypi.org/project/kontext
SummaryEasy contextual information logging
upload_time2024-04-03 08:53:12
maintainerNone
docs_urlNone
authorDanil Akhtarov
requires_python<4.0.0,>=3.7.1
licenseMIT
keywords contextvar logging context-logging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Context Information

[![PyPI](https://img.shields.io/pypi/v/kontext)](https://pypi.org/project/kontext/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/kontext)](https://www.python.org/downloads/)
[![GitHub last commit](https://img.shields.io/github/last-commit/daxartio/kontext)](https://github.com/daxartio/kontext)
[![GitHub stars](https://img.shields.io/github/stars/daxartio/kontext?style=social)](https://github.com/daxartio/kontext)

The plugin allows to transfer a context between functions. Inspired by [context-logging](https://github.com/Afonasev/context_logging).

You can use it for logging data which does not change and can be correlated, e.g. `trace_id`, `correlation_id` etc.

## Features

- Thread-safe context management
- Customizable log records
- Easy-to-use API

## Installation

```
pip install kontext
```

## Usage

```python
import logging

from kontext import Context, current_context, setup_log_record

logging.basicConfig(format="%(message)s %(kontext)s", level=logging.INFO)
logger = logging.getLogger(__name__)


def bar():
    current_context["foo"] = "bar"
    logger.info("bar")


@Context()
def foo():
    current_context["key"] = "value"
    logger.info("foo")
    bar()


setup_log_record()
foo()
logger.info("Finish")
# foo {'key': 'value'}
# bar {'key': 'value', 'foo': 'bar'}
# Finish {}

```

For more examples, please refer to the examples directory.

## License

* [MIT LICENSE](LICENSE)

## Contribution

[Contribution guidelines for this project](CONTRIBUTING.md)

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/kontext",
    "name": "kontext",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.7.1",
    "maintainer_email": null,
    "keywords": "contextvar, logging, context-logging",
    "author": "Danil Akhtarov",
    "author_email": "daxartio@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f7/ba/678e664daf60ad775e55c350e3e683a2841abe2b76034d4f3aa125b32f31/kontext-1.2.1.tar.gz",
    "platform": null,
    "description": "# Python Context Information\n\n[![PyPI](https://img.shields.io/pypi/v/kontext)](https://pypi.org/project/kontext/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/kontext)](https://www.python.org/downloads/)\n[![GitHub last commit](https://img.shields.io/github/last-commit/daxartio/kontext)](https://github.com/daxartio/kontext)\n[![GitHub stars](https://img.shields.io/github/stars/daxartio/kontext?style=social)](https://github.com/daxartio/kontext)\n\nThe plugin allows to transfer a context between functions. Inspired by [context-logging](https://github.com/Afonasev/context_logging).\n\nYou can use it for logging data which does not change and can be correlated, e.g. `trace_id`, `correlation_id` etc.\n\n## Features\n\n- Thread-safe context management\n- Customizable log records\n- Easy-to-use API\n\n## Installation\n\n```\npip install kontext\n```\n\n## Usage\n\n```python\nimport logging\n\nfrom kontext import Context, current_context, setup_log_record\n\nlogging.basicConfig(format=\"%(message)s %(kontext)s\", level=logging.INFO)\nlogger = logging.getLogger(__name__)\n\n\ndef bar():\n    current_context[\"foo\"] = \"bar\"\n    logger.info(\"bar\")\n\n\n@Context()\ndef foo():\n    current_context[\"key\"] = \"value\"\n    logger.info(\"foo\")\n    bar()\n\n\nsetup_log_record()\nfoo()\nlogger.info(\"Finish\")\n# foo {'key': 'value'}\n# bar {'key': 'value', 'foo': 'bar'}\n# Finish {}\n\n```\n\nFor more examples, please refer to the examples directory.\n\n## License\n\n* [MIT LICENSE](LICENSE)\n\n## Contribution\n\n[Contribution guidelines for this project](CONTRIBUTING.md)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Easy contextual information logging",
    "version": "1.2.1",
    "project_urls": {
        "Changelog": "https://github.com/daxartio/kontext/blob/main/CHANGELOG.md",
        "Homepage": "https://pypi.org/project/kontext",
        "Repository": "https://github.com/daxartio/kontext"
    },
    "split_keywords": [
        "contextvar",
        " logging",
        " context-logging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c8f8b32c68ac69b720ad4d8cd4ff58c73caf5bbb9e87524bb30ecda6e44cd9f",
                "md5": "b9013d056bbdf1ee27e74bf4e387e44f",
                "sha256": "fabb2a72348c04c0f0ae483c40c1ba29a4f66f31ffa4dc10e36717525b6aa2ba"
            },
            "downloads": -1,
            "filename": "kontext-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b9013d056bbdf1ee27e74bf4e387e44f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.7.1",
            "size": 4757,
            "upload_time": "2024-04-03T08:53:11",
            "upload_time_iso_8601": "2024-04-03T08:53:11.753184Z",
            "url": "https://files.pythonhosted.org/packages/4c/8f/8b32c68ac69b720ad4d8cd4ff58c73caf5bbb9e87524bb30ecda6e44cd9f/kontext-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7ba678e664daf60ad775e55c350e3e683a2841abe2b76034d4f3aa125b32f31",
                "md5": "fc77c1f0f3de65282735aa1a6ef9ad72",
                "sha256": "0218768c0254715bdb6c00a5f5273f9cc76236d8e921b1b04049a4fcd5a81de2"
            },
            "downloads": -1,
            "filename": "kontext-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "fc77c1f0f3de65282735aa1a6ef9ad72",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.7.1",
            "size": 4446,
            "upload_time": "2024-04-03T08:53:12",
            "upload_time_iso_8601": "2024-04-03T08:53:12.804841Z",
            "url": "https://files.pythonhosted.org/packages/f7/ba/678e664daf60ad775e55c350e3e683a2841abe2b76034d4f3aa125b32f31/kontext-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-03 08:53:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "daxartio",
    "github_project": "kontext",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "kontext"
}
        
Elapsed time: 0.43238s