tme_317
Running IO.inspect on a socket without truncating the result?
Hopefully a very simple question… I am troubleshooting and would like to see all the contents of a given socket using IO.inspect(). I know about using limit: :infinity to show everything in maps, lists, etc without truncation but that doesn’t seem to work with sockets. The printing is truncated with ...
Another weird thing is the socket is printed as #Phoenix.LiveView.Socket<> instead of %Phoenix.LiveView.Socket{} like a normal struct. What is a #Name<> data structure and how is it different than a struct? Couldn’t find where in the docs it is mentioned.
IO.inspect(socket, limit: :infinity)
returns this truncated result:
#Phoenix.LiveView.Socket<
assigns: %{},
changed: %{
changeset: true,
email: true,
field_errors: true,
form_error: true,
...
},
endpoint: MyAppWeb.Endpoint,
id: "phx-4dWXZ4j7",
parent_pid: nil,
view: MyAppWeb.RegistrationLive,
...
>
Marked As Solved
sb8244
LiveView derives the Inspect protocol here: phoenix_live_view/lib/phoenix_live_view/socket.ex at 900b6a3400771425f79d62e208f1fdd6b32aefd9 · phoenixframework/phoenix_live_view · GitHub
This causes the output to only include the specified fields and outputs in the <> syntax. You can see an example at https://hexdocs.pm/elixir/master/Inspect.html#module-deriving.
You may be able to use the structs: false opt to IO.inspect to get access to it.
:structs - when false, structs are not formatted by the inspect protocol, they are instead printed as maps, defaults to true.
Also Liked
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








