Commit 77fb234b37f38bf659199044cac180a4012ecba1

Stephen Moloney 2017-03-17T13:24:21

remove logs from Og and remove Og dependency

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8d6faca..c860a97 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,9 @@
 
 ## v0.3.2
 
+[changes]
+- Add default adapter `hackney` to the mix tasks.
+
 [bug fix]
 - Fix setting the query string bug (typo) - `url.encode_query(qs_map)` -> `URI.encode_query(qs_map)`
 - Problem with `Body.apply()` being called in the wrong place
diff --git a/lib/ex_ovh/config.ex b/lib/ex_ovh/config.ex
index 5fd6ceb..abff747 100644
--- a/lib/ex_ovh/config.ex
+++ b/lib/ex_ovh/config.ex
@@ -5,8 +5,7 @@ defmodule ExOvh.Config do
 
   @doc "Starts an agent for the storage of credentials in memory"
   def start_agent(client, opts) do
-    Og.log("***logging context***", __ENV__, :debug)
-    otp_app = Keyword.get(opts, :otp_app, :false) || Og.log_r(__ENV__, :error) |> raise()
+    otp_app = Keyword.get(opts, :otp_app, :false) || raise("otp_app not specified")
     Agent.start_link(fn -> config(client, otp_app) end, name: agent_name(client))
   end
 
@@ -38,7 +37,7 @@ defmodule ExOvh.Config do
         end
       end)
     rescue
-      _error -> Og.log_r("No ovh_config was found. ",  __ENV__, :warn) |> raise()
+      _error -> raise("No ovh_config was found. ")
     end
   end
 
@@ -48,8 +47,7 @@ defmodule ExOvh.Config do
       get_config_from_env(client, otp_app) |> Keyword.fetch!(:hackney)
     rescue
       _error ->
-        Og.log_r("No hackney_opts was found. " <>
-                      "Falling back to default hackney settings #{inspect(@default_hackney_opts)}", __ENV__, :warn)
+        _msg = "No hackney_opts was found. Falling back to default hackney settings #{inspect(@default_hackney_opts)}"
         @default_hackney_opts
     end
   end
diff --git a/lib/ex_ovh/supervisor.ex b/lib/ex_ovh/supervisor.ex
index 091518c..1df4abd 100644
--- a/lib/ex_ovh/supervisor.ex
+++ b/lib/ex_ovh/supervisor.ex
@@ -7,7 +7,6 @@ defmodule ExOvh.Supervisor do
 
 
   def start_link(client, opts \\ []) do
-    Og.log("***logging context***", __ENV__, :debug)
     Supervisor.start_link(__MODULE__,  {client, opts})
   end
 
@@ -16,7 +15,6 @@ defmodule ExOvh.Supervisor do
 
 
   def init({client, opts}) do
-    Og.log("***logging context***", __ENV__, :debug)
     sup_tree =
     [
     {client, {ExOvh.Config, :start_agent, [client, opts]}, :permanent, 10_000, :worker, [ExOvh.Config]}
diff --git a/lib/ex_ovh/v1/cloud.ex b/lib/ex_ovh/v1/cloud.ex
index 953eed2..b030dfb 100644
--- a/lib/ex_ovh/v1/cloud.ex
+++ b/lib/ex_ovh/v1/cloud.ex
@@ -845,7 +845,7 @@ defmodule ExOvh.V1.Cloud do
   """
   @spec create_project_alert(String.t, String.t, integer, String.t) :: HTTPipe.Conn.t | no_return
   def create_project_alert(service_name, email, monthly_threshold, delay \\ "3600") do
-    unless is_integer(monthly_threshold), do: Og.log_r("monthly_threshold should be an integer!", __ENV__, :error) |> raise()
+    unless is_integer(monthly_threshold), do: raise("monthly_threshold should be an integer!")
     body =
     %{
       "delay" => delay,
@@ -908,7 +908,7 @@ defmodule ExOvh.V1.Cloud do
   """
   @spec modify_project_alert(String.t, String.t, String.t, integer, String.t) :: HTTPipe.Conn.t
   def modify_project_alert(service_name, alert_id, email, monthly_threshold, delay \\ "3600") do
-    unless is_integer(monthly_threshold), do: Og.log_r("monthly_threshold should be an integer!", __ENV__, :error) |> raise()
+    unless is_integer(monthly_threshold), do: raise("monthly_threshold should be an integer!")
     body = %{
       "delay" => delay,
       "email" => email,
diff --git a/lib/mix/tasks/ovh.ex b/lib/mix/tasks/ovh.ex
index 13d4496..f65e090 100644
--- a/lib/mix/tasks/ovh.ex
+++ b/lib/mix/tasks/ovh.ex
@@ -192,8 +192,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp get_app_create_page(opts_map) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     method = :get
     url = Defaults.endpoints()[opts_map[:endpoint]] <> Defaults.create_app_uri_suffix()
     body = ""
@@ -217,8 +215,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp get_create_app_inputs(resp_body) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     inputs = Floki.find(resp_body, "form input")
     |> List.flatten()
     if Enum.any?(inputs, fn(input) -> input == [] end), do: raise "Empty input found"
@@ -227,8 +223,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp build_app_request(inputs, %{login: login, password: password} = opts_map) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     {acc, _index, _max} =
     Enum.reduce(inputs, {"", 1, Enum.count(inputs)}, fn({"input", input, _}, acc) ->
       name = :proplists.get_value("name", input)
@@ -255,8 +249,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp send_app_request(req_body, opts_map) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     method = :post
     url = Defaults.endpoints()[opts_map[:endpoint]] <> Defaults.create_app_uri_suffix()
     body = req_body
@@ -313,8 +305,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp get_consumer_key(%{access_rules: access_rules, redirect_uri: redirect_uri} = opts_map) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     method = :post
     url = Defaults.endpoints()[opts_map[:endpoint]] <> opts_map[:api_version] <> Defaults.consumer_key_suffix()
     body = %{ accessRules: access_rules, redirection: redirect_uri } |> Poison.encode!()
@@ -339,8 +329,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp bind_consumer_key_to_app({ck, validation_url}, opts_map) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     method = :get
     url = validation_url
     body = ""
@@ -367,8 +355,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp get_bind_ck_to_app_inputs(resp_body) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     inputs = Floki.find(resp_body, "form input") ++
     Floki.find(resp_body, "form select")
     |> List.flatten()
@@ -381,8 +367,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp build_ck_binding_request(inputs, %{login: login, password: password} = _opts_map) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     Enum.reduce(inputs, "", fn({type, input, _options}, acc) ->
       {name_val, value} =
      cond do
@@ -404,7 +388,6 @@ defmodule Mix.Tasks.Ovh do
           {name_val, value}
         true ->
           # raise "Unexpected input"
-#          Og.log("Ignoring unexpected input " <> inspect(input), __ENV__, :warn)
           {:no_name, :no_val}
       end
       case {name_val, value} do
@@ -417,8 +400,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp send_ck_binding_request(req_body, validation_url, ck) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     method = :post
     url = validation_url
     body = req_body
@@ -445,8 +426,6 @@ defmodule Mix.Tasks.Ovh do
   end
 
   defp check_for_successful_binding(resp, validation_url, ck) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     error_msg1 = "Failed to bind the consumer token to the application. Please try to validate the consumer token manually at #{validation_url}"
     error_msg2 = "Invalid validity period entered for the consumer token. Please try to validate the consumer token manually at #{validation_url}"
     cond do
@@ -463,8 +442,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp build_2fa_request(resp_body) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     Mix.Shell.IO.info("You have activated 2FA on your OVH account, you need to verify your account via 2FA")
 
     Floki.find(resp_body, "form input")
@@ -492,7 +469,6 @@ defmodule Mix.Tasks.Ovh do
           {name_val, value}
         true ->
           # raise "Unexpected input"
-#          Og.log("Ignoring unexpected input " <> inspect(input), __ENV__, :warn)
           {:no_name, :no_val}
       end
       case {name_val, value} do
@@ -505,8 +481,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp handle_2fa(resp_body, validation_url, ck) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     method = :post
     url = validation_url
     body = build_2fa_request(resp_body)
@@ -535,8 +509,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp get_credentials(opts_map) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     create_app_body = get_app_create_page(opts_map) |> get_create_app_inputs() |> build_app_request(opts_map) |> send_app_request(opts_map)
     opts_map = Map.merge(opts_map, %{
       application_key: get_application_key(create_app_body),
@@ -559,8 +531,6 @@ defmodule Mix.Tasks.Ovh do
     config_names(Atom.to_string(app_name), client_name)
   end
   defp config_names(app_name, client_name) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     {config_header, mod_client_name} =
     case app_name do
       "ex_ovh" ->
@@ -610,8 +580,6 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp print_config(options, elixir_app_name) do
-#    Og.log("***logging context***", __ENV__, :debug)
-
     app_name = elixir_app_name || options.application_name
     {config_header, mod_client_name} = config_names(app_name, options.client_name)
 
diff --git a/mix.lock b/mix.lock
index 1b8afd9..7f6930c 100644
--- a/mix.lock
+++ b/mix.lock
@@ -1,19 +1,19 @@
 %{"apex": {:hex, :apex, "1.0.0", "abf230314d35ca4c48a902f693247f190ad42fc14862b9c4f7dbb7077b21c20a", [:mix], []},
-  "calendar": {:hex, :calendar, "0.17.1", "5c7dfffde2b68011c2d6832ff1a15496292de965a3b57b3fad32405f1176f024", [:mix], [{:tzdata, "~> 0.5.8 or ~> 0.1.201603", [hex: :tzdata, optional: false]}]},
-  "certifi": {:hex, :certifi, "0.7.0", "861a57f3808f7eb0c2d1802afeaae0fa5de813b0df0979153cbafcd853ababaf", [:rebar3], []},
-  "earmark": {:hex, :earmark, "1.1.1", "433136b7f2e99cde88b745b3a0cfc3fbc81fe58b918a09b40fce7f00db4d8187", [:mix], []},
+  "calendar": {:hex, :calendar, "0.17.2", "d6b7bccc29c72203b076d4e488d967780bf2d123a96fafdbf45746fdc2fa342c", [:mix], [{:tzdata, "~> 0.5.8 or ~> 0.1.201603", [hex: :tzdata, optional: false]}]},
+  "certifi": {:hex, :certifi, "1.0.0", "1c787a85b1855ba354f0b8920392c19aa1d06b0ee1362f9141279620a5be2039", [:rebar3], []},
+  "earmark": {:hex, :earmark, "1.2.0", "bf1ce17aea43ab62f6943b97bd6e3dc032ce45d4f787504e3adf738e54b42f3a", [:mix], []},
   "ex_doc": {:hex, :ex_doc, "0.15.0", "e73333785eef3488cf9144a6e847d3d647e67d02bd6fdac500687854dd5c599f", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, optional: false]}]},
-  "floki": {:hex, :floki, "0.14.0", "91a6be57349e10a63cf52d7890479a19012cef9185fa93c305d4fe42e6a50dee", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, optional: false]}]},
-  "hackney": {:hex, :hackney, "1.6.5", "8c025ee397ac94a184b0743c73b33b96465e85f90a02e210e86df6cbafaa5065", [:rebar3], [{:certifi, "0.7.0", [hex: :certifi, optional: false]}, {:idna, "1.2.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]},
+  "floki": {:hex, :floki, "0.15.0", "c5b7ac5d585c93da4cec61fc9bac7b8c2655883a085d740871057aa30a0f1258", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, optional: false]}]},
+  "hackney": {:hex, :hackney, "1.7.1", "e238c52c5df3c3b16ce613d3a51c7220a784d734879b1e231c9babd433ac1cb4", [:rebar3], [{:certifi, "1.0.0", [hex: :certifi, optional: false]}, {:idna, "4.0.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]},
   "hoedown": {:git, "https://github.com/hoedown/hoedown.git", "980b9c549b4348d50b683ecee6abee470b98acda", []},
   "httpipe": {:hex, :httpipe, "0.9.0", "4db66493b0ec2a86d142ea959a62e221d6ddb23ab48a676b691be3a16c38a415", [:mix], []},
-  "httpipe_adapters_hackney": {:hex, :httpipe_adapters_hackney, "0.9.0", "de005d5607cbdc30a8cb71f3aa4420b6810455d0cdcfbc63ec039a4b93ba157b", [:mix], [{:hackney, "~> 1.6.0", [hex: :hackney, optional: false]}, {:httpipe, "~> 0.9.0", [hex: :httpipe, optional: false]}]},
-  "idna": {:hex, :idna, "1.2.0", "ac62ee99da068f43c50dc69acf700e03a62a348360126260e87f2b54eced86b2", [:rebar3], []},
-  "markdown": {:git, "https://github.com/devinus/markdown.git", "38dc74c88d52fd7569ad4f63d32b344d35a7fcce", []},
+  "httpipe_adapters_hackney": {:hex, :httpipe_adapters_hackney, "0.10.0", "53101fe8c2bb0753c7a18b11e495b2c38d1ec90519137a985e0633ae626b7f25", [:mix], [{:hackney, "~> 1.7.0", [hex: :hackney, optional: false]}, {:httpipe, "~> 0.9.0", [hex: :httpipe, optional: false]}]},
+  "idna": {:hex, :idna, "4.0.0", "10aaa9f79d0b12cf0def53038547855b91144f1bfcc0ec73494f38bb7b9c4961", [:rebar3], []},
+  "markdown": {:git, "https://github.com/devinus/markdown.git", "d065dbcc4e242a85ca2516fdadd0082712871fd8", []},
   "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []},
   "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []},
   "mochiweb": {:hex, :mochiweb, "2.15.0", "e1daac474df07651e5d17cc1e642c4069c7850dc4508d3db7263a0651330aacc", [:rebar3], []},
   "og": {:hex, :og, "0.2.4", "0041226e485576231abecf8a33db81557be338da2c6bcb3aedd7cac678064ae1", [:mix], [{:apex, "~> 1.0", [hex: :apex, optional: false]}]},
   "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []},
   "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []},
-  "tzdata": {:hex, :tzdata, "0.5.10", "087e8dfe8c0283473115ad8ca6974b898ecb55ca5c725427a142a79593391e90", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, optional: false]}]}}
+  "tzdata": {:hex, :tzdata, "0.5.11", "3d5469a9f46bdf4a8760333dbdabdcc4751325035c454b10521f71e7c611ae50", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, optional: false]}]}}