Fl4m3Ph03n1x

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

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe
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

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

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}>')

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54260 488
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31586 112
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42716 114
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement