{"id":22747523,"url":"https://github.com/resurfaceio/logger-python","last_synced_at":"2025-06-27T02:36:56.896Z","repository":{"id":34918733,"uuid":"189650004","full_name":"resurfaceio/logger-python","owner":"resurfaceio","description":"Log API calls with Python","archived":false,"fork":false,"pushed_at":"2024-01-08T14:35:07.000Z","size":2972,"stargazers_count":22,"open_issues_count":8,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-17T12:58:27.740Z","etag":null,"topics":["aiohttp","api-logger","django","flask","http-logger","logger-python","python","requests-module"],"latest_commit_sha":null,"homepage":"","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/resurfaceio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2019-05-31T19:47:14.000Z","updated_at":"2023-04-07T03:47:29.000Z","dependencies_parsed_at":"2024-01-08T16:03:28.507Z","dependency_job_id":null,"html_url":"https://github.com/resurfaceio/logger-python","commit_stats":{"total_commits":339,"total_committers":7,"mean_commits":48.42857142857143,"dds":"0.40117994100294985","last_synced_commit":"7fbff873feef70aa5926e4ad430c1eb4b1f173da"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/resurfaceio/logger-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resurfaceio%2Flogger-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resurfaceio%2Flogger-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resurfaceio%2Flogger-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resurfaceio%2Flogger-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/resurfaceio","download_url":"https://codeload.github.com/resurfaceio/logger-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resurfaceio%2Flogger-python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262179246,"owners_count":23271199,"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","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":["aiohttp","api-logger","django","flask","http-logger","logger-python","python","requests-module"],"created_at":"2024-12-11T03:16:13.689Z","updated_at":"2025-06-27T02:36:56.877Z","avatar_url":"https://github.com/resurfaceio.png","language":"Python","readme":"# resurfaceio-logger-python\nEasily log API requests and responses to your own \u003ca href=\"https://resurface.io\"\u003esecurity data lake\u003c/a\u003e.\n\n[![PyPI](https://img.shields.io/pypi/v/usagelogger)](https://badge.fury.io/py/usagelogger)\n[![CodeFactor](https://www.codefactor.io/repository/github/resurfaceio/logger-python/badge)](https://www.codefactor.io/repository/github/resurfaceio/logger-python)\n[![License](https://img.shields.io/github/license/resurfaceio/logger-python)](https://github.com/resurfaceio/logger-python/blob/master/LICENSE)\n[![Contributing](https://img.shields.io/badge/contributions-welcome-green.svg)](https://github.com/resurfaceio/logger-python/blob/master/CONTRIBUTING.md)\n\n## Contents\n\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"#dependencies\"\u003eDependencies\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#installing_with_pip\"\u003eInstalling With pip\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#logging_from_aiohttp\"\u003eLogging From AIOHTTP\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#logging_from_django\"\u003eLogging From Django\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#logging_from_flask\"\u003eLogging From Flask\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#logging_from_requests\"\u003eLogging From Requests\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#logging_with_api\"\u003eLogging With API\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#privacy\"\u003eProtecting User Privacy\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ca name=\"dependencies\"/\u003e\n\n## Dependencies\n\nRequires Python 3.7 or higher and a `requests` HTTP library. No other dependencies to conflict with your app.\n\n\u003ca name=\"installing_with_pip\"/\u003e\n\n## Installing With pip\n\n```\npip3 install --upgrade usagelogger\n```\n\n\u003ca name=\"logging_from_aiohttp\"/\u003e\n\n## Logging From AIOHTTP\n\n```python\nfrom aiohttp import web\nfrom usagelogger.middleware.aiohttp import HttpLoggerForAIOHTTP\n\nasync def test(request):\n    return web.Response(text=\"Hello\")\n\napp = web.Application(\n    middlewares=[\n        HttpLoggerForAIOHTTP(\n            url=\"http://localhost:7701/message\", rules=\"include debug\"\n        )\n    ]\n)\napp.router.add_get(\"/\", test)\nweb.run_app(app)\n```\n\n\u003ca name=\"logging_from_django\"/\u003e\n\n## Logging From Django\n\nFirst edit `settings.py` to register middleware, like this:\n\n*Note: We recommend placing Resurface middleware at the top in the middleware stack.*\n\n```python\nMIDDLEWARE = [\n    \"usagelogger.middleware.django.HttpLoggerForDjango\",  # Always on the top\n    \"django.middleware...\",\n]\n```\n\nThen add a new section to `settings.py` for logging configuration, like this:\n\n```python\nUSAGELOGGER = {\n    'url': 'http://localhost:7701/message', \n    'rules': 'include debug' \n}\n```\n\n\u003ca name=\"logging_from_flask\"/\u003e\n\n## Logging From Flask\n\n```python\nfrom flask import Flask\nfrom usagelogger.middleware.flask import HttpLoggerForFlask\n\napp = Flask(__name__)\n\napp.wsgi_app = HttpLoggerForFlask(  # type: ignore\n    app=app.wsgi_app, url=\"http://localhost:7701/message\", rules=\"include debug\"\n)\n\n@app.route(\"/\")\ndef home():\n    return \"This route works!\"\n\napp.run(debug=True)\n```\n\n\u003ca name=\"logging_from_requests\"/\u003e\n\n## Logging From Requests\n\n```python\nfrom usagelogger import resurface\n\ns = resurface.Session(url=\"http://localhost:7701/message\", rules=\"include debug\")\ns.get(...)\n```\n\n\u003ca name=\"logging_with_api\"/\u003e\n\n## Logging With API\n\nLoggers can be directly integrated into your application using our [API](API.md). This requires the most effort compared with\nthe options described above, but also offers the greatest flexibility and control.\n\n[API documentation](API.md)\n\n\u003ca name=\"privacy\"/\u003e\n\n## Protecting User Privacy\n\nLoggers always have an active set of \u003ca href=\"https://resurface.io/rules.html\"\u003erules\u003c/a\u003e that control what data is logged\nand how sensitive data is masked. All of the examples above apply a predefined set of rules (`include debug`),\nbut logging rules are easily customized to meet the needs of any application.\n\n\u003ca href=\"https://resurface.io/rules.html\"\u003eLogging rules documentation\u003c/a\u003e\n\n---\n\u003csmall\u003e\u0026copy; 2016-2024 \u003ca href=\"https://resurface.io\"\u003eGraylog, Inc.\u003c/a\u003e\u003c/small\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresurfaceio%2Flogger-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fresurfaceio%2Flogger-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresurfaceio%2Flogger-python/lists"}