Fl4m3Ph03n1x
How to build a reference from logs?
Background
I have some references in logs and I need to transform them from text to real references so I can compare then with ets references.
Logs and Code
I have some logs that print some errors in the form of:
"Unexpected message: {#Ref<0.427740394.3330539535.243656>,badarg}",
Now, I have some references I got from using table_ref = :ets.whereis :foo. I need to convert the reference I got from the log into something I can compare against table_ref to find out if table_ref is the same as log_ref.
Question
How can I do this?
Marked As Solved
benwilson512
iex(1)> make_ref
#Reference<0.2681540578.631242754.45080>
iex(2)> ref("0.2681540578.631242754.45080")
#Reference<0.2681540578.631242754.45080>
The ref to string conversion is just inspect, and you can do a string to ref conversion via the iex helper ref/1
Also Liked
benwilson512
It’s an IEX helper, so let’s go see how it works! https://github.com/elixir-lang/elixir/blob/v1.8.2/lib/iex/lib/iex/helpers.ex#L1258
So you can call string = "0.2681540578.631242754.45080"; :erlang.list_to_ref('#Ref<#{string}>')







