Packages
Set of wrapper functions for the built-in Logger functions `info`, `debug`, `warn`, `error`. Because the output of the functions is the same as the input, they can be inserted in a sequence of functions, that are linked with the pipe ( |> ) operator. It works the same as Elm's Debug.log.
Current section
Files
Jump to
Current section
Files
lib/plogger.ex
defmodule Plogger do
@moduledoc """
Piping logger is a set of wrapper functions for the
Elixir Logger library.
It is inspired by the logging functions in Elm:
what you pass in, comes out. This makes it easy
to log intermediate results in a sequence of function
calls.
params
|> Plogger.debug("Start")
|> some_function()
|> Plogger.debug("Step 1")
|> other_function()
|> Plogger.debug("Step 2")
The Plogger lines can be added and removed without
any further changes.
"""
require Logger
def info(payload, desc) do
Logger.info(desc <> ": " <> (inspect payload))
payload
end
def debug(payload, desc) do
Logger.debug(desc <> ": " <> (inspect payload))
payload
end
def warn(payload, desc) do
Logger.warn(desc <> ": " <> (inspect payload))
payload
end
def error(payload, desc) do
Logger.error(desc <> ": " <> (inspect payload))
payload
end
end