How to register a card / structure in an elixir

How do you register a map / struct type in ELixir without having to execute protocol String.Chars ?

 require Logger Logger.debug %{my: "map"} ** (Protocol.UndefinedError) protocol String.Chars not implemented for %{my: "map"} (elixir) lib/string/chars.ex:3: String.Chars.impl_for!/1 (elixir) lib/string/chars.ex:17: String.Chars.to_string/1 
+8
elixir
source share
2 answers

You can use inspect/2 - https://hexdocs.pm/elixir/Kernel.html#inspect/2

It analyzes the data structure in an algebra document, which can be printed using a recorder.

 iex(4)> Logger.debug inspect(%{a: 1}) 08:47:32.776 [debug] %{a: 1} :ok 
+17
source share

Elixir:

 iex(3)> %{a: 1} |> inspect |> Logger.debug 23:20:30.265 [debug] %{a: 1} :ok 
0
source share

All Articles