log token instances fetching to a separate file

pull/2779/head
Ayrat Badykov 5 years ago
parent 69d39ff42e
commit a2d947c4c8
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 5
      apps/explorer/config/dev.exs
  2. 6
      apps/explorer/config/prod.exs
  3. 14
      apps/explorer/lib/explorer/token/instance_metadata_retriever.ex
  4. 7
      apps/indexer/lib/indexer/fetcher/token_instance.ex
  5. 3
      config/config.exs

@ -18,6 +18,11 @@ config :logger, :reading_token_functions,
path: Path.absname("logs/dev/explorer/tokens/reading_functions.log"),
metadata_filter: [fetcher: :token_functions]
config :logger, :token_instances,
level: :debug,
path: Path.absname("logs/dev/explorer/tokens/token_instances.log"),
metadata_filter: [fetcher: :token_instances]
import_config "dev.secret.exs"
variant =

@ -21,6 +21,12 @@ config :logger, :reading_token_functions,
metadata_filter: [fetcher: :token_functions],
rotate: %{max_bytes: 52_428_800, keep: 19}
config :logger, :token_instances,
level: :debug,
path: Path.absname("logs/prod/explorer/tokens/token_instances.log"),
metadata_filter: [fetcher: :token_instances],
rotate: %{max_bytes: 52_428_800, keep: 19}
variant =
if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do
"parity"

@ -70,7 +70,9 @@ defmodule Explorer.Token.InstanceMetadataRetriever do
fetch_json(%{"tokenURI" => {:ok, [decoded_json]}})
rescue
e ->
Logger.error(fn -> ["Unknown metadata format #{inspect(json)}. error #{inspect(e)}"] end)
Logger.error(["Unknown metadata format #{inspect(json)}. error #{inspect(e)}"],
fetcher: :token_instances
)
{:error, json}
end
@ -81,13 +83,15 @@ defmodule Explorer.Token.InstanceMetadataRetriever do
{:ok, %{metadata: json}}
rescue
e ->
Logger.error(fn -> ["Unknown metadata format #{inspect(json)}. error #{inspect(e)}"] end)
Logger.error(["Unknown metadata format #{inspect(json)}. error #{inspect(e)}"],
fetcher: :token_instances
)
{:error, json}
end
def fetch_json(result) do
Logger.error(fn -> ["Unknown metadata format #{inspect(result)}."] end)
Logger.error(["Unknown metadata format #{inspect(result)}."], fetcher: :token_instances)
{:error, result}
end
@ -107,7 +111,9 @@ defmodule Explorer.Token.InstanceMetadataRetriever do
end
rescue
e ->
Logger.error(fn -> ["Could not send request to token uri #{inspect(token_uri)}. error #{inspect(e)}"] end)
Logger.error(["Could not send request to token uri #{inspect(token_uri)}. error #{inspect(e)}"],
fetcher: :token_instances
)
{:error, :request_error}
end

@ -72,14 +72,15 @@ defmodule Indexer.Fetcher.TokenInstance do
{:ok, _result} = Chain.upsert_token_instance(params)
result ->
Logger.error(fn ->
Logger.error(
[
"failed to fetch token instance metadata for #{
inspect({to_string(token_contract_address_hash), Decimal.to_integer(token_id)})
}: ",
inspect(result)
]
end)
],
fetcher: :token_instances
)
:ok
end

@ -26,8 +26,7 @@ config :logger,
# only :indexer, but all levels
{LoggerFileBackend, :indexer},
{LoggerFileBackend, :indexer_token_balances},
{LoggerFileBackend, :failed_contract_creations},
{LoggerFileBackend, :addresses_without_code},
{LoggerFileBackend, :token_instances},
{LoggerFileBackend, :reading_token_functions}
]

Loading…
Cancel
Save