Skip to content

Make it easy to log request/responses #2854

Open
@dblock

Description

@dblock

Version: What redis-py and what redis version is the issue happening on?

Redis-py 4.6.0
Redis 6.2.10

Platform: What platform / version? (For example Python 3.5.1 on Windows 7 / Ubuntu 15.10 / Azure)

MacOS

Description: Description of your issue, stack traces from errors and code that reproduces the issue

I'd like to log request/responses from the client (and can't find how to do it after trying very hard ;)). Looking for equivalent functionality of httpx:

def log_request(request):
    print(f"> {request.method} {request.url}")

def log_response(response):
    request = response.request
    print(f"< {request.method} {request.url} - {response.status_code}")

def main():
    client = Client(
        ...
        event_hooks={
            "request": [log_request],
            "response": [log_response],
        },
    )

Is there a way to achieve this with redis-py, otherwise wdyt about adding a feature that makes this easy?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions