Add logger
This commit is contained in:
parent
d1bc22f745
commit
a391104a28
|
@ -1,3 +1,5 @@
|
|||
use Mix.Config
|
||||
|
||||
config :issues, github_url: "https://api.github.com"
|
||||
|
||||
config :logger, compile_time_purge_level: :info
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
defmodule Issues.GithubIssues do
|
||||
|
||||
require Logger
|
||||
|
||||
@user_agent [ { "User-agent", "Elixir dave@pragprog.com" } ]
|
||||
# use a module attribute to fetch the value at compile time
|
||||
@github_url Application.get_env(:issues, :github_url)
|
||||
|
||||
def fetch(user, project) do
|
||||
Logger.info("Fetching #{user}'s project #{project}")
|
||||
|
||||
issues_url(user, project)
|
||||
|> HTTPoison.get(@user_agent)
|
||||
|> handle_response
|
||||
|
@ -15,6 +19,8 @@ defmodule Issues.GithubIssues do
|
|||
end
|
||||
|
||||
def handle_response( {:ok, %{status_code: status_code, body: body}} ) do
|
||||
Logger.info("Got response: status code=#{status_code}")
|
||||
Logger.debug(fn -> inspect(body) end)
|
||||
{
|
||||
status_code |> check_for_error(),
|
||||
body |> Poison.Parser.parse!()
|
||||
|
|
Loading…
Reference in New Issue