Skip to main content

Log outgoing requests made by the requests python library

Project description

1 django-log-outgoing-requests

Version:

0.1.0

Source:

https://github.com/maykinmedia/django-log-outgoing-requests

Keywords:

logging

PythonVersion:

3.9

Build status Code quality checks black Coverage status Documentation Status

python-versions django-versions pypi-version

Log and save outgoing requests made by requests library

2 Features

  • Log outgoing requests

  • Save logs in database

  • Overview of the saved logs in the admin page

3 Installation

3.1 Requirements

  • Python 3.7 or above

  • setuptools 30.3.0 or above

  • Django 3.2 or newer

3.2 Install

pip install django-log-outgoing-requests

4 Usage

To use this with your project you need to follow these steps:

  1. Add Django Log Outgoing Requests to INSTALLED_APPS in your Django project’s settings.py:

    INSTALLED_APPS = (
      # ...,
      "log_outgoing_requests"
    )
  2. Update your settings.py file with the following (if you haven’t defined logging yet, you can see the Django’s documentation):

    from log_outgoing_requests.formatters import HttpFormatter
    
    
    LOGGING = {
        #...,
        "formatters": {
            #...,
            "outgoing_requests": {"()": HttpFormatter},
        },
        "handlers": {
            #...,
            "log_outgoing_requests": {
                "level": "DEBUG",
                "formatter": "outgoing_requests",
                "class": "logging.StreamHandler",
            },
            "save_outgoing_requests": {
                "level": "DEBUG",
                "class": "log_outgoing_requests.handlers.DatabaseOutgoingRequestsHandler",
            },
        },
        "loggers": {
            #...,
            "requests": {
                "handlers": ["log_outgoing_requests", "save_outgoing_requests"],
                "level": "DEBUG",
                "propagate": True,
            },
        },
    }
    
    LOG_OUTGOING_REQUESTS_DB_SAVE = True # save logs enabled/disabled based on the boolean value
  3. Run the migrations

    python manage.py migrate

5 Local development

To install and develop the library locally, use:

pip install -e --no-build-isolation .[tests,coverage,docs,pep8,release]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-log-outgoing-requests-0.1.0.tar.gz (8.5 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page