Skip to content

Commit

Permalink
Log the request in debug mode (#125)
Browse files Browse the repository at this point in the history
* Log the request in debug mode

* Fixing typo in request logging
  • Loading branch information
RyanSiu1995 authored and scrogson committed Dec 20, 2018
1 parent 68941eb commit 3468cdb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/oauth2/request.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule OAuth2.Request do
@moduledoc false


require Logger
import OAuth2.Util

alias OAuth2.{Client, Error, Response, Serializer}
Expand All @@ -20,6 +21,17 @@ defmodule OAuth2.Request do
headers = process_request_headers(headers, content_type)
req_opts = Keyword.merge(client.request_opts, opts)

if Application.get_env(:oauth2, :debug) do
Logger.debug("""
OAuth2 Provider Request
url: #{inspect url}
method: #{inspect method}
headers: #{inspect headers}
body: #{inspect body}
req_opts: #{inspect req_opts}
""")
end

case :hackney.request(method, url, headers, body, req_opts) do
{:ok, ref} when is_reference(ref) ->
{:ok, ref}
Expand Down

0 comments on commit 3468cdb

Please sign in to comment.