Raw/mangled output on errors

I have an old codebase that logs the errors in a raw/mangled form.

Every time a server error occurs, there is a wall of red text that looks like this:

16:23:37.212 [error] Ranch listener App.Endpoint.HTTP, connection process #PID<0.1053.0>, stream 1 had its request process #PID<0.1054.0> exit with reason {{%RuntimeError{message: “cannot encode metadata from the :meta field for App.Foo to JSON. This metadata is used internally by ecto and should never be exposed externally.\n\nYou can either map the schemas to remove the :meta field before encoding to JSON, or explicit list the JSON fields in your schema:\n\n defmodule App.Foo do\n # …\n\n @derive {Poison.Encoder, only: [:name, :title, …]}\n schema … do\n”}, [{Poison.Encoder.Ecto.Schema.Metadata, :encode, 2, [file: ‘lib/ecto/json.ex’, line: 35]}, {Poison.Encoder.Map, :"-encode/3-fun-1-", 4, [file: ‘lib/poison/encoder.ex’, line: 227]}, {Poison.Encoder.Map, :"-encode/3-lists^foldl/2-0-", 3, [file: ‘lib/poison/encoder.ex’, line: 228]}, {Poison.Encoder.Map, :encode, 3, [file: ‘lib/poison/encoder.ex’, line: 228]}, {Poison.Encoder.List, :"-encode/3-fun-0-", 3, [file: ‘lib/poison/encoder.ex’, line: 259]}, {Poison.Encoder.List, :"-encode/3-lists^foldr/2-1-", 3, [file: ‘lib/poison/encoder.ex’, line: 260]}, {Poison.Encoder.List, :encode, 3, [file: ‘lib/poison/encoder.ex’, line: 260]}, {Poison.Encoder.Map, :"-encode/3-fun-1-", 4, [file: ‘lib/poison/encoder.ex’, line: 227]}, {Poison.Encoder.Map, :"-encode/3-lists^foldl/2-0-", 3, [file: ‘lib/poison/encoder.ex’, line: 228]}, {Poison.Encoder.Map, :encode, 3, [file: ‘lib/poison/encoder.ex’, line: 228]}, {Poison.Encoder.Map, :"-encode/3-fun-1-", 4, [file: ‘lib/poison/encoder.ex’, line: 227]}, {Poison.Encoder.Map, :"-encode/3-lists^foldl/2-0-", 3, [file: ‘lib/poison/encoder.ex’, line: 228]}, {Poison.Encoder.Map, :encode, 3, [file: ‘lib/poison/encoder.ex’, line: 228]}, {Poison, :encode!, 2, [file: ‘lib/poison.ex’, line: 41]}, {Phoenix.Controller, :put_render, 5, [file: ‘lib/phoenix/controller.ex’, line: 729]}, {Phoenix.Controller, :instrument_render_and_send, 4, [file: ‘lib/phoenix/controller.ex’, line: 746]}, {App.FooController, :action, 2,

Any idea what do I need to change in order to have the errors pretty printed?

What you mean by “pretty printed”?

something like this:

[error] #PID<0.501.0> running AppWeb.Endpoint (connection #PID<0.500.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /
** (exit) an exception was raised:
    ** (ArithmeticError) bad argument in arithmetic expression
        (app) lib/app_web/controllers/page_controller.ex:5: AppWeb.PageController.index/2
        (app) lib/app_web/controllers/page_controller.ex:1: AppWeb.PageController.action/2
        (app) lib/app_web/controllers/page_controller.ex:1: AppWeb.PageController.phoenix_controller_pipeline/2
        (app) lib/app_web/endpoint.ex:1: AppWeb.Endpoint.instrument/4
        (phoenix) lib/phoenix/router.ex:275: Phoenix.Router.__call__/1
        (app) lib/app_web/endpoint.ex:1: AppWeb.Endpoint.plug_builder_call/2
        (app) lib/plug/debugger.ex:122: AppWeb.Endpoint."call (overridable 3)"/2
        (app) lib/app_web/endpoint.ex:1: AppWeb.Endpoint.call/2
        (phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:33: Phoenix.Endpoint.Cowboy2Handler.init/2
        (cowboy) /LearningStuff/elixir/app/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2
        (cowboy) /LearningStuff/elixir/app/deps/cowboy/src/cowboy_stream_h.erl:296: :cowboy_stream_h.execute/3
        (cowboy) /LearningStuff/elixir/app/deps/cowboy/src/cowboy_stream_h.erl:274: :cowboy_stream_h.request_process/3
        (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

the raw/mangled output from the original message looks like a datastructure that could be used to display this “pretty” output.