GithubHelp home page GithubHelp logo

exdebug's Introduction

ExDebug

Module Version Hex Docs Total Download License Last Updated

Elixir library with debugging functions for making life easier.

Table of Contents

Installation

The package can be installed by adding ex_debug to your list of dependencies in mix.exs:

def deps do
  [
    {:ex_debug, "~> 1.0.0"}
  ]
end

Configuration

When using the ExDebug.console\2 function, it's possible to pass some formatting options to the function. There is a configuration in config/config.exs file that can be adjusted to set these options globally:

# config/config.exs file

config :ex_debug,
  width: 80,
  color: 255,
  line_color: 238,
  time_color: 247,
  syntax_colors: [
    atom:    :cyan,
    binary:  :white,
    boolean: :magenta,
    list:    :white,
    map:     :white,
    nil:     :magenta,
    number:  :yellow,
    regex:   :light_red,
    reset:   :yellow,
    string:  :green,
    tuple:   :white
  ]
  • width: Lenght of characters to be used in the console print.

  • color: Color of the label if its given. Values between 0-255.

  • line_color: Color of the header and footer lines. Values between 0-255.

  • time_color: Color of the execution time. Values between 0-255.

  • syntax_colors: Keyword list for term syntax color.

    Keys: :atom, :binary, :boolean, :list, :map, :nil, :number, :regex, :reset, :string, :tuple.

    Values: :black, :red, :yellow, :green, :cyan, :blue, :magenta, :white, :light_black, :light_red, :light_yellow, :light_green, :light_cyan, :light_blue, :light_magenta, :light_white.

256 color palette

palette image

Usage

ExDebug.console

Use the ExDebug.console\2 function chaining it anywhere in your functions pipelines, to print in console the current data on that point of the pipeline.

This behavior is only present in the dev and test environments. If it's called in the prod (or any other) environment, it will simply ignore the command and pass through the data.

The second argument of the function is optional. It's a keyword list of options: :width, :color, :line_color, :time_color, :syntax_colors.

Example

iex> "Lorem-Ipsum"
...> |> String.split("-")
...> |> ExDebug.console(label: "Split return")
...> |> Enum.join()
...> |> String.downcase()
# Split return -------------------------------------- 2022-03-10 - 00:47:07.523741
# ["Lorem", "Ipsum"]
# ------------------------------------------------------------------- MyApp v0.0.0
"loremipsum" # <- This is the actual pipeline return, besides de console print.

Development

The test suite can be executed as follows:

mix test

exdebug's People

Contributors

josepamplona avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.