PassiveSupport.Logging (passive_support v0.8.3)

Helper functions for logging and inspecting.

These functions serve two primary purposes and one subtle but kinda nice purpose:

  1. To keep outputs colorized even when they're sent to Logger,
  2. To keep IO.inspect and Kernel.inspect from truncating away data you might need if you intend, e.g., to save a function's return as fixture data for debugging purposes
  3. Not needing to temporarily require Logger when you're debugging a module

Link to this section Summary

Link to this section Functions

Link to this function

alert(item \\ nil, label \\ nil)

Link to this function

coloration_opts()

Specs

coloration_opts() ::
  {:syntax_colors,
   [
     number: :yellow,
     string: :green,
     list: :light_magenta,
     map: :light_cyan,
     atom: :light_blue,
     tuple: :"[:black_background, :white]",
     regex: :"[:cyan_background, :light_yellow]"
   ]}

Pretty good, pretty pretty, color choices for inspected data

Link to this function

critical(item \\ nil, label \\ nil)

Link to this function

debug(item \\ nil, label \\ nil)

Link to this function

emergency(item \\ nil, label \\ nil)

Link to this function

error(item \\ nil, label \\ nil)

Link to this function

info(item \\ nil, label \\ nil)

Link to this function

inspect(item, to_log \\ false)

calls Kernel.inspect/2 on item with logger_opts/0.

If you wish to overwrite some portion of the opts send to inspect, consider calling Kernel.inspect and passing Utils.logger_opts() ++ overwrites as your opts instead of calling this function.

Specs

inspect_opts() :: [
  printable_limit: :infinity,
  limit: :infinity,
  width: 170,
  pretty: true
]

Sensible defaults for see a value in its entirety through IO.inspect and Kernel.inspect

Specs

logger_opts() :: [
  syntax_colors: [
    number: :yellow,
    string: :green,
    list: :light_magenta,
    map: :light_cyan,
    atom: :light_blue,
    tuple: :"[:black_background, :white]",
    regex: :"[:cyan_background, :light_yellow]"
  ],
  printable_limit: :infinity,
  limit: :infinity,
  width: 170,
  pretty: true
]

Sensible option defaults for logging information to stdout

Link to this function

notice(item \\ nil, label \\ nil)

Link to this function

warn(item \\ nil, label \\ nil)