%global _empty_manifest_terminate_build 0 Name: python-django-structlog Version: 5.0.1 Release: 1 Summary: Structured Logging for Django License: MIT URL: https://pypi.org/project/django-structlog/ Source0: https://mirrors.nju.edu.cn/pypi/web/packages/b9/5e/fa0f4caa322b003904769b86a3938941d717243b94b3ce3ad0dcad854a70/django-structlog-5.0.1.tar.gz BuildArch: noarch Requires: python3-django Requires: python3-structlog Requires: python3-asgiref Requires: python3-django-ipware Requires: python3-celery %description | |pypi| |wheels| |build-status| |docs| |coverage| |open_issues| |pull_requests| | |django| |python| |license| |black| | |watchers| |stars| |forks| django-structlog is a structured logging integration for `Django `_ project using `structlog `_ Logging will then produce additional cohesive metadata on each logs that makes it easier to track events or incidents. Additional Popular Integrations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Django REST framework `_ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``Django REST framework`` is supported by default. But when using it with ``rest_framework.authentication.TokenAuthentication`` (or other DRF authentications) ``user_id`` will be only be in ``request_finished`` and ``request_failed`` instead of each logs. See `#37 `_ for details. `Celery `_ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Celery's task logging requires additional configurations, see `documentation `_ for details. Logging comparison ^^^^^^^^^^^^^^^^^^ Standard logging: ~~~~~~~~~~~~~~~~~ >>> import logging >>> logger = logging.get_logger(__name__) >>> logger.info("An error occurred") An error occurred Well... ok With django-structlog and flat_line: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> import structlog >>> logger = structlog.get_logger(__name__) >>> logger.info("an_error_occurred", bar="Buz") timestamp='2019-04-13T19:39:31.089925Z' level='info' event='an_error_occurred' logger='my_awesome_project.my_awesome_module' request_id='3a8f801c-072b-4805-8f38-e1337f363ed4' user_id=1 ip='0.0.0.0' bar='Buz' Then you can search with commands like: $ cat logs/flat_line.log | grep request_id='3a8f801c-072b-4805-8f38-e1337f363ed4' With django-structlog and json ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> import structlog >>> logger = structlog.get_logger(__name__) >>> logger.info("an_error_occurred", bar="Buz") {"request_id": "3a8f801c-072b-4805-8f38-e1337f363ed4", "user_id": 1, "ip": "0.0.0.0", "event": "an_error_occurred", "timestamp": "2019-04-13T19:39:31.089925Z", "logger": "my_awesome_project.my_awesome_module", "level": "info", "bar": "Buz"} Then you can search with commands like: $ cat logs/json.log | jq '.[] | select(.request_id="3a8f801c-072b-4805-8f38-e1337f363ed4")' -s %package -n python3-django-structlog Summary: Structured Logging for Django Provides: python-django-structlog BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-django-structlog | |pypi| |wheels| |build-status| |docs| |coverage| |open_issues| |pull_requests| | |django| |python| |license| |black| | |watchers| |stars| |forks| django-structlog is a structured logging integration for `Django `_ project using `structlog `_ Logging will then produce additional cohesive metadata on each logs that makes it easier to track events or incidents. Additional Popular Integrations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Django REST framework `_ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``Django REST framework`` is supported by default. But when using it with ``rest_framework.authentication.TokenAuthentication`` (or other DRF authentications) ``user_id`` will be only be in ``request_finished`` and ``request_failed`` instead of each logs. See `#37 `_ for details. `Celery `_ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Celery's task logging requires additional configurations, see `documentation `_ for details. Logging comparison ^^^^^^^^^^^^^^^^^^ Standard logging: ~~~~~~~~~~~~~~~~~ >>> import logging >>> logger = logging.get_logger(__name__) >>> logger.info("An error occurred") An error occurred Well... ok With django-structlog and flat_line: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> import structlog >>> logger = structlog.get_logger(__name__) >>> logger.info("an_error_occurred", bar="Buz") timestamp='2019-04-13T19:39:31.089925Z' level='info' event='an_error_occurred' logger='my_awesome_project.my_awesome_module' request_id='3a8f801c-072b-4805-8f38-e1337f363ed4' user_id=1 ip='0.0.0.0' bar='Buz' Then you can search with commands like: $ cat logs/flat_line.log | grep request_id='3a8f801c-072b-4805-8f38-e1337f363ed4' With django-structlog and json ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> import structlog >>> logger = structlog.get_logger(__name__) >>> logger.info("an_error_occurred", bar="Buz") {"request_id": "3a8f801c-072b-4805-8f38-e1337f363ed4", "user_id": 1, "ip": "0.0.0.0", "event": "an_error_occurred", "timestamp": "2019-04-13T19:39:31.089925Z", "logger": "my_awesome_project.my_awesome_module", "level": "info", "bar": "Buz"} Then you can search with commands like: $ cat logs/json.log | jq '.[] | select(.request_id="3a8f801c-072b-4805-8f38-e1337f363ed4")' -s %package help Summary: Development documents and examples for django-structlog Provides: python3-django-structlog-doc %description help | |pypi| |wheels| |build-status| |docs| |coverage| |open_issues| |pull_requests| | |django| |python| |license| |black| | |watchers| |stars| |forks| django-structlog is a structured logging integration for `Django `_ project using `structlog `_ Logging will then produce additional cohesive metadata on each logs that makes it easier to track events or incidents. Additional Popular Integrations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Django REST framework `_ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``Django REST framework`` is supported by default. But when using it with ``rest_framework.authentication.TokenAuthentication`` (or other DRF authentications) ``user_id`` will be only be in ``request_finished`` and ``request_failed`` instead of each logs. See `#37 `_ for details. `Celery `_ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Celery's task logging requires additional configurations, see `documentation `_ for details. Logging comparison ^^^^^^^^^^^^^^^^^^ Standard logging: ~~~~~~~~~~~~~~~~~ >>> import logging >>> logger = logging.get_logger(__name__) >>> logger.info("An error occurred") An error occurred Well... ok With django-structlog and flat_line: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> import structlog >>> logger = structlog.get_logger(__name__) >>> logger.info("an_error_occurred", bar="Buz") timestamp='2019-04-13T19:39:31.089925Z' level='info' event='an_error_occurred' logger='my_awesome_project.my_awesome_module' request_id='3a8f801c-072b-4805-8f38-e1337f363ed4' user_id=1 ip='0.0.0.0' bar='Buz' Then you can search with commands like: $ cat logs/flat_line.log | grep request_id='3a8f801c-072b-4805-8f38-e1337f363ed4' With django-structlog and json ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> import structlog >>> logger = structlog.get_logger(__name__) >>> logger.info("an_error_occurred", bar="Buz") {"request_id": "3a8f801c-072b-4805-8f38-e1337f363ed4", "user_id": 1, "ip": "0.0.0.0", "event": "an_error_occurred", "timestamp": "2019-04-13T19:39:31.089925Z", "logger": "my_awesome_project.my_awesome_module", "level": "info", "bar": "Buz"} Then you can search with commands like: $ cat logs/json.log | jq '.[] | select(.request_id="3a8f801c-072b-4805-8f38-e1337f363ed4")' -s %prep %autosetup -n django-structlog-5.0.1 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-django-structlog -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Mon Apr 10 2023 Python_Bot - 5.0.1-1 - Package Spec generated