seanmonstar/warp

Logging of query params

bobrippling opened this issue · 0 comments

Is your feature request related to a problem? Please describe.
I'd like to be able to log out the query parameters of a request, to aid in development of a webserver where I'd like to see what query parameters a blackbox client is sending up.

Describe the solution you'd like
A way to have the query parameters in log output, like so:

INFO myhttp > 127.0.0.1:61128 "GET /api/bob.json HTTP/1.1" 200 "-" "curl/7.85.0" 7.290966ms

# becoming

INFO myhttp > 127.0.0.1:61128 "GET /api/bob.json?frobnicate&percumbulator=7 HTTP/1.1" 200 "-" "curl/7.85.0" 7.290966ms
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Describe alternatives ideas you've considered
I'd like to expose Route::query on log's Info struct, perhaps as two methods:

  • pub fn query_params(&self) -> &str returns ?x=1&y=2
    (possibly returning String if the &str isn't available)
  • pub fn path_with_query(&self) -> &str returns /api/whatever?x=1&y=2
    (same)
  • We could optionally add warp::log::with_query to do this automatically, alongside warp::log.

If these ideas aren't too controversial, I'm happy to make a PR for them.