{"id":31804361,"url":"https://github.com/vishalanandl177/drf-api-logger","last_synced_at":"2025-10-11T01:57:45.950Z","repository":{"id":37719680,"uuid":"301002406","full_name":"vishalanandl177/DRF-API-Logger","owner":"vishalanandl177","description":"An API Logger for your Django Rest Framework project.","archived":false,"fork":false,"pushed_at":"2025-09-06T17:03:51.000Z","size":741,"stargazers_count":325,"open_issues_count":2,"forks_count":61,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-09-24T21:37:12.079Z","etag":null,"topics":["django-rest-framework","logger","logger-signals","python","python3"],"latest_commit_sha":null,"homepage":"https://github.com/vishalanandl177/DRF-API-Logger","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vishalanandl177.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-10-03T23:33:19.000Z","updated_at":"2025-09-23T08:48:45.000Z","dependencies_parsed_at":"2024-03-09T06:23:15.897Z","dependency_job_id":"d9cfeb3c-5e7b-4de8-a917-e8c90ce0b963","html_url":"https://github.com/vishalanandl177/DRF-API-Logger","commit_stats":{"total_commits":58,"total_committers":11,"mean_commits":"5.2727272727272725","dds":0.3275862068965517,"last_synced_commit":"457653e91ffb8ee40e2a799dcbd743cbbd5ebf92"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/vishalanandl177/DRF-API-Logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vishalanandl177%2FDRF-API-Logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vishalanandl177%2FDRF-API-Logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vishalanandl177%2FDRF-API-Logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vishalanandl177%2FDRF-API-Logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vishalanandl177","download_url":"https://codeload.github.com/vishalanandl177/DRF-API-Logger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vishalanandl177%2FDRF-API-Logger/sbom","scorecard":{"id":923438,"data":{"date":"2025-08-04","repo":{"name":"github.com/vishalanandl177/DRF-API-Logger","commit":"0ec67c74f8f47f58728b700f8f73b3c24542f2a6"},"scorecard":{"version":"v5.2.1-28-gc1d103a9","commit":"c1d103a9bb9f635ec7260bf9aa0699466fa4be0e"},"score":1.5,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 2/21 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#license"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact 1.1.19 not signed: https://api.github.com/repos/vishalanandl177/DRF-API-Logger/releases/210620810","Warn: release artifact 1.1.16 not signed: https://api.github.com/repos/vishalanandl177/DRF-API-Logger/releases/167522561","Warn: release artifact 1.1.15 not signed: https://api.github.com/repos/vishalanandl177/DRF-API-Logger/releases/127571190","Warn: release artifact 1.1.14 not signed: https://api.github.com/repos/vishalanandl177/DRF-API-Logger/releases/111577948","Warn: release artifact 1.1.13 not signed: https://api.github.com/repos/vishalanandl177/DRF-API-Logger/releases/111539753","Warn: release artifact 1.1.19 does not have provenance: https://api.github.com/repos/vishalanandl177/DRF-API-Logger/releases/210620810","Warn: release artifact 1.1.16 does not have provenance: https://api.github.com/repos/vishalanandl177/DRF-API-Logger/releases/167522561","Warn: release artifact 1.1.15 does not have provenance: https://api.github.com/repos/vishalanandl177/DRF-API-Logger/releases/127571190","Warn: release artifact 1.1.14 does not have provenance: https://api.github.com/repos/vishalanandl177/DRF-API-Logger/releases/111577948","Warn: release artifact 1.1.13 does not have provenance: https://api.github.com/repos/vishalanandl177/DRF-API-Logger/releases/111539753"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 12 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"34 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2024-230 / GHSA-248v-346w-9cwc","Warn: Project is vulnerable to: PYSEC-2023-135 / GHSA-xqr8-7jwr-rhp7","Warn: Project is vulnerable to: GHSA-3ww4-gg4f-jr7f","Warn: Project is vulnerable to: GHSA-5cpq-8wj7-hf2v","Warn: Project is vulnerable to: PYSEC-2024-225 / GHSA-6vqw-3v5j-54x4","Warn: Project is vulnerable to: GHSA-9v9h-cgj8-h64p","Warn: Project is vulnerable to: GHSA-h4gh-qq45-vh27","Warn: Project is vulnerable to: PYSEC-2023-254 / GHSA-jfhm-5ghh-2f97","Warn: Project is vulnerable to: GHSA-jm77-qphf-c4w8","Warn: Project is vulnerable to: GHSA-v8gr-m533-ghj9","Warn: Project is vulnerable to: GHSA-w7pp-m8wf-vj6r","Warn: Project is vulnerable to: GHSA-x4qr-2fvf-3mr5","Warn: Project is vulnerable to: PYSEC-2023-13 / GHSA-2hrw-hx67-34x6","Warn: Project is vulnerable to: PYSEC-2023-225 / GHSA-7h4p-27mh-hmrw","Warn: Project is vulnerable to: GHSA-7xr5-9hcq-chf9","Warn: Project is vulnerable to: PYSEC-2023-226 / GHSA-h8gc-pgj2-vjm3","Warn: Project is vulnerable to: PYSEC-2023-100 / GHSA-jh3w-4vvf-mjgr","Warn: Project is vulnerable to: PYSEC-2023-12 / GHSA-q2jf-h9jm-m7p4","Warn: Project is vulnerable to: PYSEC-2023-222 / GHSA-qmf9-6jqf-j8fq","Warn: Project is vulnerable to: PYSEC-2023-61 / GHSA-r3xc-prgr-mg9p","Warn: Project is vulnerable to: GHSA-rrqc-c2jx-6jgv","Warn: Project is vulnerable to: GHSA-gw84-84pc-xp82","Warn: Project is vulnerable to: PYSEC-2023-117 / GHSA-mrwq-x4v8-fh7p","Warn: Project is vulnerable to: GHSA-9hjg-9r4m-mvj7","Warn: Project is vulnerable to: GHSA-9wx4-h78v-vm56","Warn: Project is vulnerable to: PYSEC-2023-74 / GHSA-j8r2-6x86-q33q","Warn: Project is vulnerable to: GHSA-2m57-hf25-phgg","Warn: Project is vulnerable to: PYSEC-2023-87 / GHSA-rrm6-wvj7-cwh2","Warn: Project is vulnerable to: GHSA-g7vv-2v7x-gj9p","Warn: Project is vulnerable to: GHSA-34jh-p97f-mpxf","Warn: Project is vulnerable to: PYSEC-2023-212 / GHSA-g4mx-q9vg-27p4","Warn: Project is vulnerable to: GHSA-pq67-6m6q-mj2v","Warn: Project is vulnerable to: PYSEC-2023-192 / GHSA-v845-jxx5-vc9f","Warn: Project is vulnerable to: GHSA-jfmj-5v4g-7637"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-25T07:07:19.197Z","repository_id":37719680,"created_at":"2025-08-25T07:07:19.197Z","updated_at":"2025-08-25T07:07:19.197Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005915,"owners_count":26083989,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django-rest-framework","logger","logger-signals","python","python3"],"created_at":"2025-10-11T01:57:37.031Z","updated_at":"2025-10-11T01:57:45.938Z","avatar_url":"https://github.com/vishalanandl177.png","language":"Python","funding_links":["https://buymeacoffee.com/riptechlead"],"categories":[],"sub_categories":[],"readme":"# DRF API Logger\n\n[![Version](https://img.shields.io/badge/version-1.1.21-blue.svg)](https://github.com/vishalanandl177/DRF-API-Logger)\n[![Python](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org)\n[![Django](https://img.shields.io/badge/django-3.2+-green.svg)](https://djangoproject.com)\n[![DRF](https://img.shields.io/badge/djangorestframework-3.12+-orange.svg)](https://www.django-rest-framework.org)\n[![Downloads](https://static.pepy.tech/personalized-badge/drf-api-logger?period=total\u0026left_color=black\u0026right_color=orange\u0026left_text=Downloads)](http://pepy.tech/project/drf-api-logger)\n[![License](https://img.shields.io/badge/license-Apache%202.0-red.svg)](https://opensource.org/licenses/Apache-2.0)\n\n**A comprehensive API logging solution for Django Rest Framework projects that captures detailed request/response information with zero performance impact.**\n\n## 🚀 Key Features\n\nDRF API Logger automatically captures and stores comprehensive API information:\n\n- **📍 Request Details**: URL, method, headers, body, and client IP\n- **📊 Response Information**: Status code, response body, and execution time  \n- **🔒 Security**: Automatic masking of sensitive data (passwords, tokens)\n- **⚡ Performance**: Non-blocking background processing with configurable queuing\n- **🎯 Flexible Storage**: Database logging and/or real-time signal notifications\n- **📈 Analytics**: Built-in admin dashboard with charts and performance metrics\n- **🔧 Highly Configurable**: Extensive filtering and customization options\n\n### 🌐 Community \u0026 Support\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://discord.gg/eeYansFDCT\"\u003e\u003cimg src=\"https://img.shields.io/badge/Discord-7289DA?style=for-the-badge\u0026logo=discord\u0026logoColor=white\" alt=\"Join Discord\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://www.instagram.com/coderssecret/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge\u0026logo=instagram\u0026logoColor=white\" alt=\"Follow on Instagram\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/vishalanandl177\"\u003e\u003cimg src=\"https://img.shields.io/badge/GitHub-100000?style=for-the-badge\u0026logo=github\u0026logoColor=white\" alt=\"GitHub Profile\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://buymeacoffee.com/riptechlead\"\u003e\u003cimg src=\"https://img.shields.io/badge/Buy%20Me%20A%20Coffee-FFDD00?style=for-the-badge\u0026logo=buy-me-a-coffee\u0026logoColor=black\" alt=\"Support\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## 📦 Installation\n\n### 1. Install Package\n\n```bash\npip install drf-api-logger\n```\n\n### 2. Django Configuration\n\nAdd `drf_api_logger` to your `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n    # ... your other apps\n    'drf_api_logger',\n]\n```\n\nAdd the API logger middleware:\n\n```python\nMIDDLEWARE = [\n    # ... your other middleware\n    'drf_api_logger.middleware.api_logger_middleware.APILoggerMiddleware',\n]\n```\n\n### 3. Database Migration (Optional)\n\nIf using database logging, run migrations:\n\n```bash\npython manage.py migrate\n```\n\n## ⚙️ Quick Start\n\n### Database Logging\n\nEnable database storage for API logs:\n\n```python\n# settings.py\nDRF_API_LOGGER_DATABASE = True\n```\n\n**Features:**\n- 📊 **Admin Dashboard**: View logs in Django Admin with charts and analytics\n- 🔍 **Advanced Search**: Search across request body, response, headers, and URLs  \n- 🎛️ **Smart Filtering**: Filter by date, status code, HTTP method, and performance\n- 📈 **Visual Analytics**: Built-in performance charts and statistics\n\n### Admin Dashboard Screenshots\n\n\u003cdiv align=\"center\"\u003e\n\n| Feature | Screenshot |\n|---------|------------|\n| **📊 Overview \u0026 Analytics** | ![Analytics](https://raw.githubusercontent.com/vishalanandl177/DRF-API-Logger/master/graph.png) |\n| **📋 Log Listing** | ![Log List](https://raw.githubusercontent.com/vishalanandl177/DRF-API-Logger/master/lists.png) |\n| **🔍 Detailed View** | ![Log Details](https://raw.githubusercontent.com/vishalanandl177/DRF-API-Logger/master/details.png) |\n\n\u003c/div\u003e\n\n### Signal-Based Logging\n\nEnable real-time signal notifications for custom logging solutions:\n\n```python\n# settings.py\nDRF_API_LOGGER_SIGNAL = True\n```\n\n#### Signal Usage Example\n\n```python\nfrom drf_api_logger import API_LOGGER_SIGNAL\n\n# Create signal listeners\ndef log_to_file(**kwargs):\n    \"\"\"Log API data to file\"\"\"\n    with open('api_logs.json', 'a') as f:\n        json.dump(kwargs, f)\n        f.write('\\n')\n\ndef send_to_analytics(**kwargs):\n    \"\"\"Send API data to analytics service\"\"\"\n    analytics_service.track_api_call(\n        url=kwargs['api'],\n        method=kwargs['method'],\n        status_code=kwargs['status_code'],\n        execution_time=kwargs['execution_time']\n    )\n\n# Subscribe to signals\nAPI_LOGGER_SIGNAL.listen += log_to_file\nAPI_LOGGER_SIGNAL.listen += send_to_analytics\n\n# Unsubscribe when needed\nAPI_LOGGER_SIGNAL.listen -= log_to_file\n```\n\n**Signal Data Structure:**\n```python\n{\n    'api': '/api/users/',\n    'method': 'POST',\n    'status_code': 201,\n    'headers': '{\"Content-Type\": \"application/json\"}',\n    'body': '{\"username\": \"john\", \"password\": \"***FILTERED***\"}',\n    'response': '{\"id\": 1, \"username\": \"john\"}',\n    'client_ip_address': '192.168.1.100',\n    'execution_time': 0.142,\n    'added_on': datetime.now(),\n    'tracing_id': 'uuid4-string'  # if tracing enabled\n}\n```\n\n## 🔧 Configuration Options\n\n### Performance Optimization\n\nControl background processing and database performance:\n\n```python\n# Queue size for batch database insertion\nDRF_LOGGER_QUEUE_MAX_SIZE = 50  # Default: 50\n\n# Time interval for processing queue (seconds)\nDRF_LOGGER_INTERVAL = 10  # Default: 10 seconds\n```\n\n### Selective Logging\n\n**Skip by Namespace:**\n```python\n# Skip entire Django apps\nDRF_API_LOGGER_SKIP_NAMESPACE = ['admin', 'api_v1_internal']\n```\n\n**Skip by URL Name:**\n```python\n# Skip specific URL patterns\nDRF_API_LOGGER_SKIP_URL_NAME = ['health-check', 'metrics']\n```\n\n**Filter by HTTP Method:**\n```python\n# Log only specific methods\nDRF_API_LOGGER_METHODS = ['GET', 'POST', 'PUT', 'DELETE']\n```\n\n**Filter by Status Code:**\n```python\n# Log only specific status codes\nDRF_API_LOGGER_STATUS_CODES = [200, 201, 400, 401, 403, 404, 500]\n```\n\n\u003e **Note:** Admin panel requests are automatically excluded from logging.\n\n### Security \u0026 Privacy\n\n**Data Masking:**\n```python\n# Automatically mask sensitive fields (default)\nDRF_API_LOGGER_EXCLUDE_KEYS = ['password', 'token', 'access', 'refresh', 'secret']\n# Result: {\"password\": \"***FILTERED***\", \"username\": \"john\"}\n```\n\n**Database Configuration:**\n```python\n# Use specific database for logs\nDRF_API_LOGGER_DEFAULT_DATABASE = 'logging_db'  # Default: 'default'\n```\n\n### Performance Monitoring\n\n**Slow API Detection:**\n```python\n# Mark APIs slower than threshold as \"slow\" in admin\nDRF_API_LOGGER_SLOW_API_ABOVE = 200  # milliseconds\n```\n\n**Response Size Limits:**\n```python\n# Prevent logging large payloads\nDRF_API_LOGGER_MAX_REQUEST_BODY_SIZE = 1024   # bytes, -1 for no limit\nDRF_API_LOGGER_MAX_RESPONSE_BODY_SIZE = 2048  # bytes, -1 for no limit\n```\n\n### Content Type \u0026 Timezone\n\n**Custom Content Types:**\n```python\n# Extend supported content types\nDRF_API_LOGGER_CONTENT_TYPES = [\n    \"application/json\",           # Default\n    \"application/vnd.api+json\",   # JSON API\n    \"application/xml\",            # XML\n    \"text/csv\",                   # CSV\n]\n```\n\n**Timezone Display:**\n```python\n# Admin timezone offset (display only, doesn't affect storage)\nDRF_API_LOGGER_TIMEDELTA = 330   # IST (UTC+5:30) = 330 minutes\nDRF_API_LOGGER_TIMEDELTA = -300  # EST (UTC-5:00) = -300 minutes\n```\n\n### Path Configuration\n\n**URL Storage Format:**\n```python\nDRF_API_LOGGER_PATH_TYPE = 'ABSOLUTE'  # Options: ABSOLUTE, FULL_PATH, RAW_URI\n```\n\n| Option | Example Output |\n|--------|----------------|\n| `ABSOLUTE` (default) | `http://127.0.0.1:8000/api/v1/?page=123` |\n| `FULL_PATH` | `/api/v1/?page=123` |\n| `RAW_URI` | `http://127.0.0.1:8000/api/v1/?page=123` (bypasses host validation) |\n\n### Request Tracing\n\n**Enable Request Tracing:**\n```python\nDRF_API_LOGGER_ENABLE_TRACING = True  # Default: False\n```\n\n**Custom Tracing Function:**\n```python\n# Use custom UUID generator\nDRF_API_LOGGER_TRACING_FUNC = 'myapp.utils.generate_trace_id'\n\ndef generate_trace_id():\n    return f\"trace-{uuid.uuid4()}\"\n```\n\n**Extract Tracing from Headers:**\n```python\n# Use existing tracing header\nDRF_API_LOGGER_TRACING_ID_HEADER_NAME = 'X-Trace-ID'\n```\n\n**Access Tracing ID in Views:**\n```python\ndef my_api_view(request):\n    if hasattr(request, 'tracing_id'):\n        logger.info(f\"Processing request {request.tracing_id}\")\n    return Response({'status': 'ok'})\n```\n\n## 📊 Programmatic Access\n\n### Querying Log Data\n\nAccess log data programmatically when database logging is enabled:\n\n```python\nfrom drf_api_logger.models import APILogsModel\n\n# Get successful API calls\nsuccessful_apis = APILogsModel.objects.filter(status_code__range=(200, 299))\n\n# Find slow APIs\nslow_apis = APILogsModel.objects.filter(execution_time__gt=1.0)\n\n# Recent errors\nrecent_errors = APILogsModel.objects.filter(\n    status_code__gte=400,\n    added_on__gte=timezone.now() - timedelta(hours=1)\n).order_by('-added_on')\n\n# Popular endpoints\npopular_endpoints = APILogsModel.objects.values('api').annotate(\n    count=Count('id')\n).order_by('-count')[:10]\n```\n\n### Model Schema\n\n```python\nclass APILogsModel(models.Model):\n    id = models.BigAutoField(primary_key=True)\n    api = models.CharField(max_length=1024, help_text='API URL')\n    headers = models.TextField()\n    body = models.TextField()\n    method = models.CharField(max_length=10, db_index=True)\n    client_ip_address = models.CharField(max_length=50)\n    response = models.TextField()\n    status_code = models.PositiveSmallIntegerField(db_index=True)\n    execution_time = models.DecimalField(decimal_places=5, max_digits=8)\n    added_on = models.DateTimeField()\n```\n\n## 🔧 Testing\n\nThe package includes comprehensive test coverage:\n\n```bash\n# Install test dependencies\npip install -e .\n\n# Run core tests\npython test_runner_simple.py\n\n# Run full test suite  \npython run_tests.py\n\n# With coverage\ncoverage run --source drf_api_logger run_tests.py\ncoverage report\n```\n\nFor detailed testing instructions, see [TESTING.md](TESTING.md).\n\n## 🚀 Performance \u0026 Production\n\n### Database Optimization\n\nFor high-traffic applications:\n\n1. **Use a dedicated database** for logs:\n   ```python\n   DRF_API_LOGGER_DEFAULT_DATABASE = 'logs_db'\n   ```\n\n2. **Optimize queue settings**:\n   ```python\n   DRF_LOGGER_QUEUE_MAX_SIZE = 100    # Larger batches\n   DRF_LOGGER_INTERVAL = 5            # More frequent processing\n   ```\n\n3. **Add database indexes**:\n   ```sql\n   CREATE INDEX idx_api_logs_added_on ON drf_api_logs(added_on);\n   CREATE INDEX idx_api_logs_api_method ON drf_api_logs(api, method);\n   ```\n\n4. **Archive old data** periodically:\n   ```python\n   # Delete logs older than 30 days\n   old_logs = APILogsModel.objects.filter(\n       added_on__lt=timezone.now() - timedelta(days=30)\n   )\n   old_logs.delete()\n   ```\n\n### Performance Impact\n\n- **Zero impact** on API response times (background processing)\n- **Minimal memory footprint** (configurable queue limits)\n- **Efficient storage** (bulk database operations)\n\n## 🤝 Contributing\n\nWe welcome contributions! Please read our [Contributing Guide](CONTRIBUTING.md) for details.\n\n### Development Setup\n\n```bash\ngit clone https://github.com/vishalanandl177/DRF-API-Logger.git\ncd DRF-API-Logger\npip install -e .\nmake test-core  # Run tests\n```\n\n## 📄 License\n\nThis project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.\n\n## 🌟 Acknowledgments\n\n- Built with ❤️ for the Django and DRF community\n- Inspired by the need for comprehensive API monitoring\n- Thanks to all contributors and users\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**⭐ Star this repo if you find it useful!**\n\n[Report Bug](https://github.com/vishalanandl177/DRF-API-Logger/issues) • [Request Feature](https://github.com/vishalanandl177/DRF-API-Logger/issues) • [Documentation](https://github.com/vishalanandl177/DRF-API-Logger/wiki)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvishalanandl177%2Fdrf-api-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvishalanandl177%2Fdrf-api-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvishalanandl177%2Fdrf-api-logger/lists"}