Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
blockscout/apps/indexer/lib/indexer/logger.ex

33 lines
744 B

defmodule Indexer.Logger do
@moduledoc """
Helpers for `Logger`.
"""
@doc """
Sets `keyword` in `Logger.metadata/1` around `fun`.
"""
def metadata(fun, keyword) when is_function(fun, 0) and is_list(keyword) do
metadata_before = Logger.metadata()
try do
Logger.metadata(keyword)
fun.()
after
Logger.reset_metadata(metadata_before)
end
end
@doc """
The PID and its registered name (if it has one) as `t:iodata/0`.
"""
def process(pid) when is_pid(pid) do
prefix = [inspect(pid)]
{:registered_name, registered_name} = Process.info(pid, :registered_name)
case registered_name do
[] -> prefix
_ -> [prefix, " (", inspect(registered_name), ")"]
end
end
end