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! elixir/lib/iex/lib/iex/helpers.ex at v1.8.2 · elixir-lang/elixir · GitHub
So you can call string = "0.2681540578.631242754.45080"; :erlang.list_to_ref('#Ref<#{string}>')
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








