I have an action:
def my_action(conn, params) do
# ..............
Logger.info("test: params #{IO.inspect(params)};\r\n\r\n")
This causes an exception:
** (Protocol.UndefinedError) protocol String.Chars not implemented for %{"key1" => "var1", "key2" => "var2", # ........}.
This protocol is implemented for: Atom, BitString.................
I comprehend what it means, but I can't understand why it's caused? I'm using "inspect". What should I use instead to fix it?
IO.inspect
prints the value and then returns the value. Other than printing the value, it's the same as writing
"test: params #{params};\r\n\r\n"
What you need here is Kernel.inspect
or simply inspect
:
Logger.info("test: params #{inspect(params)};\r\n\r\n")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With