request-id-helper-0.2.0
توضیحات
Helper to add request id in logger and context
| ویژگی | مقدار |
|---|---|
| سیستم عامل | POSIX |
| نام فایل | request-id-helper-0.2.0 |
| نام | request-id-helper |
| نسخه کتابخانه | 0.2.0 |
| نگهدارنده | ['Pavel Liashkov'] |
| ایمیل نگهدارنده | ['pavel.liashkov@protonmail.com'] |
| نویسنده | Pavel Liashkov |
| ایمیل نویسنده | pavel.liashkov@protonmail.com |
| آدرس صفحه اصلی | https://github.com/bigbag/request-id-helper |
| آدرس اینترنتی | https://pypi.org/project/request-id-helper/ |
| مجوز | Apache License, Version 2.0 |
# request-id-helper
[](https://github.com/bigbag/request-id-helper/actions?query=workflow%3ACI)
[](https://codecov.io/gh/bigbag/request-id-helper)
[](https://pypi.python.org/pypi/request-id-helper)
[](https://pypistats.org/packages/request-id-helper)
[](https://github.com/bigbag/request-id-helper)
[](https://github.com/bigbag/request-id-helper/blob/master/LICENSE)
**request-id-helper** is a helper to add request id in logger and context.
* [Project Changelog](https://github.com/bigbag/request-id-helper/blob/main/CHANGELOG.md)
## Installation
request-id-helper is available on PyPI.
Use pip to install:
$ pip install request-id-helper
## Basic Usage
```py
import logging
from request_id_helper import init_logger, set_request_id
logger = logging.getLogger(__name__)
LOGGING = {
"version": 1,
"disable_existing_loggers": 0,
"formatters": {
"default": {
"()": "request_id_helper.RequestIdFormatter",
"format": "[%(asctime)s] %(levelname)s [%(request_id)s] %(name)s | %(message)s",
"datefmt": "%d/%b/%Y %H:%M:%S",
}
},
"handlers": {
"stdout": {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "default",
},
},
"loggers": {
"": {
"handlers": ["stdout"],
"propagate": True,
"level": "INFO",
},
},
}
def main():
init_logger(LOGGING)
@set_request_id()
def my_function() -> int:
logger.info("Demo")
return 10
my_function()
if __name__ == "__main__":
main()
```
```bash
[17/Oct/2024 20:13:02] INFO [459cb386-5947-4eec-b3d8-266605f40444] __main__ | Demo
```
## License
request-id-helper is developed and distributed under the Apache 2.0 license.
## Reporting a Security Vulnerability
See our [security policy](https://github.com/bigbag/request-id-helper/security/policy).
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl request-id-helper-0.2.0:
pip install request-id-helper-0.2.0.whl
نصب پکیج tar.gz request-id-helper-0.2.0:
pip install request-id-helper-0.2.0.tar.gz