Probe v1.0.1 Probe View Source

Provides simple print-style debugging macros.

Instead of attempting to debug your code using inline placements of IO.inspect, e.g.

def some_func, do: :some_value

case some_func() |> IO.inspect do
  # case handling
end

you instead use one of Probe’s macros:

require Probe

case some_func() |> Probe.i do
  # case handling
end

this will do the same as IO.inspect, that is pipe the result of some_func() to standard out and return it, but will also label the output with the source of the value, e.g. in this case it will output:

some_func() :some_value

and use ANSI escape sequences to colour the label (if supported, i.e. IO.ANSI.enabled?() returns true)

If you want, you can provide a custom label for the value:

some_func() |> Probe.i("what is this?")
what is this? :some_value
:some_value
# or
%{some: :value} |> Probe.i(:some)
:some %{some: :value}
%{some: :value}

This gives the convenience of the IO.inspect insertion style of debugging but allows you to map results to debugging statements through the use of the labels.

If you want to highlight specific debugging statements to make them easier to pick-out then use one of the provided style macros, e.g.:

some_func() |> Probe.red()
some_func() |> Probe.green()
some_func() |> Probe.reverse() # equivalent to Probe.i, Probe.d
some_func() |> Probe.white_bg()
# etc

Disabling

Since Probe is built as a set of macros, if you disable it using:

config :probe, disabled: true

in (say) config/prod.exs then the debugging code with be completely removed at compile time and the statement:

calculate() |> Probe.red()

will compile to the equivalent of calling calculate() on its own.

Link to this section Summary

Functions

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :blue

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :blue_background

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :bright

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :cyan

A debugging macro that outputs debugging information highlighed using the IO.ANSI style [:cyan_background, :black]

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :reverse

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :green

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :green_background

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :reverse

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :magenta

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :magenta_background

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :red

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :red_background

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :reverse

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :white

A debugging macro that outputs debugging information highlighed using the IO.ANSI style [:white_background, :black]

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :yellow

A debugging macro that outputs debugging information highlighed using the IO.ANSI style [:yellow_background, :black]

Link to this section Functions

Link to this macro blue(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :blue.

some_func() |> Probe.blue()      # => " some_func() <value>"
some_func() |> Probe.blue(:func) # => " :func <value>"
Probe.blue(some_func(), :tag)    # => " :tag <value>"
Link to this macro blue_bg(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :blue_background.

some_func() |> Probe.blue_bg()      # => " some_func() <value>"
some_func() |> Probe.blue_bg(:func) # => " :func <value>"
Probe.blue_bg(some_func(), :tag)    # => " :tag <value>"
Link to this macro bright(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :bright.

some_func() |> Probe.bright()      # => " some_func() <value>"
some_func() |> Probe.bright(:func) # => " :func <value>"
Probe.bright(some_func(), :tag)    # => " :tag <value>"
Link to this macro cyan(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :cyan.

some_func() |> Probe.cyan()      # => " some_func() <value>"
some_func() |> Probe.cyan(:func) # => " :func <value>"
Probe.cyan(some_func(), :tag)    # => " :tag <value>"
Link to this macro cyan_bg(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style [:cyan_background, :black].

some_func() |> Probe.cyan_bg()      # => " some_func() <value>"
some_func() |> Probe.cyan_bg(:func) # => " :func <value>"
Probe.cyan_bg(some_func(), :tag)    # => " :tag <value>"
Link to this macro d(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :reverse.

some_func() |> Probe.d()      # => " some_func() <value>"
some_func() |> Probe.d(:func) # => " :func <value>"
Probe.d(some_func(), :tag)    # => " :tag <value>"
Link to this macro green(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :green.

some_func() |> Probe.green()      # => " some_func() <value>"
some_func() |> Probe.green(:func) # => " :func <value>"
Probe.green(some_func(), :tag)    # => " :tag <value>"
Link to this macro green_bg(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :green_background.

some_func() |> Probe.green_bg()      # => " some_func() <value>"
some_func() |> Probe.green_bg(:func) # => " :func <value>"
Probe.green_bg(some_func(), :tag)    # => " :tag <value>"
Link to this macro i(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :reverse.

some_func() |> Probe.i()      # => " some_func() <value>"
some_func() |> Probe.i(:func) # => " :func <value>"
Probe.i(some_func(), :tag)    # => " :tag <value>"
Link to this macro magenta(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :magenta.

some_func() |> Probe.magenta()      # => " some_func() <value>"
some_func() |> Probe.magenta(:func) # => " :func <value>"
Probe.magenta(some_func(), :tag)    # => " :tag <value>"
Link to this macro magenta_bg(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :magenta_background.

some_func() |> Probe.magenta_bg()      # => " some_func() <value>"
some_func() |> Probe.magenta_bg(:func) # => " :func <value>"
Probe.magenta_bg(some_func(), :tag)    # => " :tag <value>"
Link to this macro red(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :red.

some_func() |> Probe.red()      # => " some_func() <value>"
some_func() |> Probe.red(:func) # => " :func <value>"
Probe.red(some_func(), :tag)    # => " :tag <value>"
Link to this macro red_bg(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :red_background.

some_func() |> Probe.red_bg()      # => " some_func() <value>"
some_func() |> Probe.red_bg(:func) # => " :func <value>"
Probe.red_bg(some_func(), :tag)    # => " :tag <value>"
Link to this macro reverse(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :reverse.

some_func() |> Probe.reverse()      # => " some_func() <value>"
some_func() |> Probe.reverse(:func) # => " :func <value>"
Probe.reverse(some_func(), :tag)    # => " :tag <value>"
Link to this macro white(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :white.

some_func() |> Probe.white()      # => " some_func() <value>"
some_func() |> Probe.white(:func) # => " :func <value>"
Probe.white(some_func(), :tag)    # => " :tag <value>"
Link to this macro white_bg(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style [:white_background, :black].

some_func() |> Probe.white_bg()      # => " some_func() <value>"
some_func() |> Probe.white_bg(:func) # => " :func <value>"
Probe.white_bg(some_func(), :tag)    # => " :tag <value>"
Link to this macro yellow(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style :yellow.

some_func() |> Probe.yellow()      # => " some_func() <value>"
some_func() |> Probe.yellow(:func) # => " :func <value>"
Probe.yellow(some_func(), :tag)    # => " :tag <value>"
Link to this macro yellow_bg(expression, label \\ nil) View Source (macro)

A debugging macro that outputs debugging information highlighed using the IO.ANSI style [:yellow_background, :black].

some_func() |> Probe.yellow_bg()      # => " some_func() <value>"
some_func() |> Probe.yellow_bg(:func) # => " :func <value>"
Probe.yellow_bg(some_func(), :tag)    # => " :tag <value>"