From a2d947c4c8e1353a4016622edbb8aef5a0550b26 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 15 Oct 2019 16:31:34 +0300 Subject: [PATCH] log token instances fetching to a separate file --- apps/explorer/config/dev.exs | 5 +++++ apps/explorer/config/prod.exs | 6 ++++++ .../explorer/token/instance_metadata_retriever.ex | 14 ++++++++++---- apps/indexer/lib/indexer/fetcher/token_instance.ex | 7 ++++--- config/config.exs | 3 +-- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/apps/explorer/config/dev.exs b/apps/explorer/config/dev.exs index 95019470fc..a9d0f53b15 100644 --- a/apps/explorer/config/dev.exs +++ b/apps/explorer/config/dev.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 = diff --git a/apps/explorer/config/prod.exs b/apps/explorer/config/prod.exs index 0957ffa1f7..0137d44ae5 100644 --- a/apps/explorer/config/prod.exs +++ b/apps/explorer/config/prod.exs @@ -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" diff --git a/apps/explorer/lib/explorer/token/instance_metadata_retriever.ex b/apps/explorer/lib/explorer/token/instance_metadata_retriever.ex index 92b9c8be97..2dcad087ef 100644 --- a/apps/explorer/lib/explorer/token/instance_metadata_retriever.ex +++ b/apps/explorer/lib/explorer/token/instance_metadata_retriever.ex @@ -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 diff --git a/apps/indexer/lib/indexer/fetcher/token_instance.ex b/apps/indexer/lib/indexer/fetcher/token_instance.ex index 14936d05af..929891be21 100644 --- a/apps/indexer/lib/indexer/fetcher/token_instance.ex +++ b/apps/indexer/lib/indexer/fetcher/token_instance.ex @@ -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 diff --git a/config/config.exs b/config/config.exs index 17d60558e6..c6a4ed5043 100644 --- a/config/config.exs +++ b/config/config.exs @@ -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} ]