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"), path: Path.absname("logs/dev/explorer/tokens/reading_functions.log"),
metadata_filter: [fetcher: :token_functions] 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" import_config "dev.secret.exs"
variant = variant =

@ -21,6 +21,12 @@ config :logger, :reading_token_functions,
metadata_filter: [fetcher: :token_functions], metadata_filter: [fetcher: :token_functions],
rotate: %{max_bytes: 52_428_800, keep: 19} 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 = variant =
if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do
"parity" "parity"

@ -70,7 +70,9 @@ defmodule Explorer.Token.InstanceMetadataRetriever do
fetch_json(%{"tokenURI" => {:ok, [decoded_json]}}) fetch_json(%{"tokenURI" => {:ok, [decoded_json]}})
rescue rescue
e -> 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} {:error, json}
end end
@ -81,13 +83,15 @@ defmodule Explorer.Token.InstanceMetadataRetriever do
{:ok, %{metadata: json}} {:ok, %{metadata: json}}
rescue rescue
e -> 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} {:error, json}
end end
def fetch_json(result) do 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} {:error, result}
end end
@ -107,7 +111,9 @@ defmodule Explorer.Token.InstanceMetadataRetriever do
end end
rescue rescue
e -> 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} {:error, :request_error}
end end

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

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

Loading…
Cancel
Save