All Projects → Sija → debug.cr

Sija / debug.cr

Licence: MIT License
Debug macro for Crystal

Programming Languages

crystal
512 projects

Labels

Projects that are alternatives of or similar to debug.cr

PlutoTest.jl
✔️ Visual, reactive testing library for Julia. Time machine included.
Stars: ✭ 56 (-34.88%)
Mutual labels:  debugging
gha
🔧 Test your GitHub Actions workflow locally.
Stars: ✭ 53 (-38.37%)
Mutual labels:  debugging
pytest-faulthandler
py.test plugin that activates the fault handler module during testing
Stars: ✭ 27 (-68.6%)
Mutual labels:  debugging
debugger
Debugging helper for Go
Stars: ✭ 54 (-37.21%)
Mutual labels:  debugging
docker-pudb
Debug Python code within a Docker container remotely from your terminal using pudb
Stars: ✭ 18 (-79.07%)
Mutual labels:  debugging
InAppDevTools
Android library with a collection of tools for debugging, inspecting and reporting from within your own app
Stars: ✭ 26 (-69.77%)
Mutual labels:  debugging
ssh2actions
Connect to GitHub Actions VM via SSH for interactive debugging
Stars: ✭ 62 (-27.91%)
Mutual labels:  debugging
pydbg
Python implementation of the Rust `dbg` macro
Stars: ✭ 85 (-1.16%)
Mutual labels:  debugging
deno-debug
Debugging utility for deno. Ported from https://npmjs.com/debug
Stars: ✭ 15 (-82.56%)
Mutual labels:  debugging
WhatTheStack
See a pretty error screen when your Android app crashes
Stars: ✭ 240 (+179.07%)
Mutual labels:  debugging
ircpdb
Remotely and collaboratively debug your Python application via an IRC channel.
Stars: ✭ 59 (-31.4%)
Mutual labels:  debugging
kokkos-tools
Kokkos C++ Performance Portability Programming EcoSystem: Profiling and Debugging Tools
Stars: ✭ 52 (-39.53%)
Mutual labels:  debugging
devmod
Developer Module for debugging web applications
Stars: ✭ 16 (-81.4%)
Mutual labels:  debugging
SandboxBrowser
A simple iOS sandbox file browser, you can share files through AirDrop
Stars: ✭ 84 (-2.33%)
Mutual labels:  debugging
ynm3k
ynm3k.readthedocs.io
Stars: ✭ 20 (-76.74%)
Mutual labels:  debugging
SmartDump
SmartDump - an exception and memory dump capture utility
Stars: ✭ 17 (-80.23%)
Mutual labels:  debugging
use-debugger-hooks
A small package of custom React hooks that are useful for debugging changes in React hook dependencies across renders
Stars: ✭ 44 (-48.84%)
Mutual labels:  debugging
CSS-Lecture-And-Exercises
🎨 Get to know CSS! It's fun!
Stars: ✭ 11 (-87.21%)
Mutual labels:  debugging
r2lldb
radare2-lldb integration
Stars: ✭ 54 (-37.21%)
Mutual labels:  debugging
CrashLogger
A dll injected into process to dump stack when crashing.
Stars: ✭ 19 (-77.91%)
Mutual labels:  debugging

debug!(…)

CI Releases License

A macro for puts-style debugging fans.

Debuggers are great. But sometimes you just don't have the time and nerve to set up everything correctly and just want a quick way to inspect some values at runtime.

This projects provides debug!(…) macro that can be used in all circumstances where you would typically write puts … or pp …, but with a few extras.

Features

  • Easy to read, colorized output
  • Prints file name, line number, function name and the original expression
  • Adds type information for the printed-out value
  • Specialized pretty-printers for selected classes and modules (like Indexable)
  • Can be used inside expressions

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      debug:
        github: Sija/debug.cr
  2. Run shards install

  3. Make sure you compile your program with ENV variable DEBUG set to 1 (for instance DEBUG=1 shards build). Otherwise all debug!(…) calls will become a no-op.

  4. Once your program is compiled, you need to pass DEBUG=1 again on the program start, in order to activate debug!(…) logging. Alternatively, you can call Debug.enabled = true within your code to achieve the same behaviour.

Usage

require "debug"

# You can use `debug!(...)` in expressions:
def factorial(n : Int)
  return debug!(1) if debug!(n <= 1)
  debug!(n * factorial(n - 1))
end

message = "hello"
debug!(message)

a = 2
b = debug!(3 * a) + 1

numbers = {b, 13, 42}
debug!(numbers)

debug!("this line is executed")

factorial(4)

The code above produces this output:

debug!(…) macro output

Configuration

You can change the global defaults by calling Debug.configure with a block:

Debug.configure do |settings|
  settings.max_path_length = 100

  settings.colors[:expression] = :magenta
  settings.colors[:value] = :yellow
end

There's also Debug::Logger.configure method which allows you to change global defaults related to the logging itself.

Debug::Logger.configure do |settings|
  settings.progname = "foo.cr"

  settings.show_severity = false
  settings.show_datetime = true
  settings.show_progname = true

  settings.colors[:datetime] = :dark_gray
  settings.colors[:progname] = :light_blue

  settings.severity_colors[:debug] = :cyan
  settings.severity_colors[:info] = :white
end

Customization

If you want debug!(…) to work for your custom class, you can simply overload #to_debug(io) method within your class.

class Foo
  def to_debug(io)
    io << "Foo(@bar = " << @bar.to_s.colorize(:green) << ")"
  end
end

Development

Run specs with:

crystal spec

Contributing

  1. Fork it (https://github.com/Sija/debug.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • @Sija Sijawusz Pur Rahnama - creator, maintainer
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].