Skip to content

Commit

Permalink
Add debug output (#2)
Browse files Browse the repository at this point in the history
* Fix Avrora.Config.schemas_path default value
* Bump version to 0.2.1
  • Loading branch information
Strech authored Jul 16, 2019
1 parent 230c128 commit 6e2c07e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ config :avrora,
schemas_path: Path.expand("./priv/schemas"),
registry_url: nil

config :logger, :console, format: "$time $metadata[$level] $levelpad(Avrora) $message\n"
config :logger, :console, format: "$time $metadata[$level] $levelpad$message\n"
2 changes: 1 addition & 1 deletion lib/avrora/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule Avrora.Config do
"""

@doc false
def schemas_path, do: get_env(:schemas_path, Path.expand("../../priv/schemas"))
def schemas_path, do: get_env(:schemas_path, Path.expand("./priv/schemas"))

@doc false
def registry_url, do: get_env(:registry_url, nil)
Expand Down
3 changes: 3 additions & 0 deletions lib/avrora/storage/file.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ defmodule Avrora.Storage.File do
)
end

Logger.debug("reading schema `#{schema_name.name}` from the file #{filepath}")

Schema.parse(body)
end
end

@doc false
def get(key) when is_integer(key), do: {:error, :unsupported}

@doc false
def put(_key, _value), do: {:error, :unsupported}

Expand Down
6 changes: 6 additions & 0 deletions lib/avrora/storage/registry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ defmodule Avrora.Storage.Registry do
{:ok, version} <- Map.fetch(response, "version"),
{:ok, schema} <- Map.fetch(response, "schema"),
{:ok, schema} <- Schema.parse(schema) do
Logger.debug("obtaining schema #{schema_name.name} with version `#{version}`")

{:ok, %{schema | version: version}}
end
end
Expand All @@ -48,6 +50,8 @@ defmodule Avrora.Storage.Registry do
with {:ok, response} <- http_client_get("schemas/ids/#{key}"),
{:ok, schema} <- Map.fetch(response, "schema"),
{:ok, schema} <- Schema.parse(schema) do
Logger.debug("obtaining schema with global id `#{key}`")

{:ok, %{schema | id: key}}
end
end
Expand All @@ -74,6 +78,8 @@ defmodule Avrora.Storage.Registry do
)
end

Logger.debug("new schema `#{schema_name.name}` stored with global id `#{id}`")

{:ok, %{schema | id: id}}
end
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Avrora.MixProject do
def project do
[
app: :avrora,
version: "0.2.0",
version: "0.2.1",
elixir: "~> 1.6",
description: description(),
package: package(),
Expand Down

0 comments on commit 6e2c07e

Please sign in to comment.