Examine

Examine enhances Elixir IO.inspect debugging by displaying results alongside code and execution times.

Additional Features

The Examine.inspect/2 macro only affects the :dev environment by default and will compile to a noop in other environments. The affected environments can be changed via config, or per call via the :ignore_env option.

Documentation can be found at https://hexdocs.pm/examine.

Installation

Add :examine to your list of dependencies in mix.exs:

def deps do
[
{:examine, "~> 0.2.0"}
]
end

Require the Examine module wherever you want to use it:

defmodule SomeModule
require Examine
def one_plus_two do
Examine.inspect(1 + 2)
end
end

Examples

Simple Usage

Examine.inspect(1 + 2)

Example 1 Screenshot

Pipeline and Vars

list = [1, 2, 3]
list
|> Enum.map(&{&1, to_string(&1 * &1)})
|> Enum.into(%{})
|> Examine.inspect(show_vars: true)

Example 3 Screenshot

Inspecting a Pipeline

list = [1, 2, 3]
list
|> Enum.map(&{&1, to_string(&1 * &1)})
|> Enum.into(%{})
|> Examine.inspect(inspect_pipeline: true, show_vars: true)

Example 4 Screenshot

Inspecting a Pipeline with Anonymous Function

list = [1, 2, 3]
list
|> Enum.map(&{&1, to_string(&1 * &1)})
|> (fn val ->
:timer.sleep(1000)
val
end).()
|> Enum.into(%{})
|> Examine.inspect(inspect_pipeline: true)

Example 5 Screenshot

Setting Various Options

start = 1
increment = 1
start
|> Kernel.+(increment)
|> Kernel.+(increment)
|> Kernel.+(increment)
|> Kernel.+(increment)
|> Examine.inspect(
inspect_pipeline: true,
color: :yellow,
bg_color: :blue,
show_vars: true,
time_unit: :nanosecond,
label: "Setting A Lot of Options"
)

Example 6 Screenshot

Acknowledgements

https://github.com/romul/dbg_inspect