Skip to content

DebugMe

DebugMe Logo

A Classic Debugging Technique That Never Gets Old

Printing labeled variable values to STDOUT is one of the oldest and most fundamental debugging techniques in computer science. From the earliest days of programming, developers have relied on simple output statements to understand what their code is doing. While modern debuggers offer sophisticated features like breakpoints and step-through execution, there's something elegantly simple and universally effective about printing variables to see their values in real-time.

**DebugMe** embraces this time-tested approach, making it effortless to inspect local, instance, and class variables with clearly labeled output. Sometimes the old ways are the best ways.


Key Features

  • Variable Inspection - Display labeled values of local, instance, and class variables
  • Flexible Output - Customize tags, timestamps, headers, and output destinations
  • Global Control - Enable/disable all debug output via $DEBUG_ME flag
  • Zero Overhead - When disabled, debug blocks aren't evaluated
  • Logger Integration - Works with Ruby's Logger and Rails.logger
  • Call Stack Support - Optionally include backtrace information

Quick Example

require 'debug_me'
include DebugMe

name = "Ruby"
version = 3.2
features = [:ractors, :fiber_scheduler]

debug_me { [:name, :version, :features] }

# With a custom tag (shorthand syntax)
debug_me('INIT') { [:name, :version] }
# Equivalent to: debug_me(tag: 'INIT') { [:name, :version] }

Output:

DEBUG  [2025-01-06 12:30:45.123456]  example.rb:7
   name -=> "Ruby"
   version -=> 3.2
   features -=> [:ractors, :fiber_scheduler]

Why DebugMe?

Feature DebugMe puts debugger
Labeled output ✅ ❌ N/A
Source location ✅ ❌ ✅
Zero overhead when disabled ✅ ❌ ✅
No code changes to disable ✅ ❌ ❌
Works in production ✅ ✅ ❌
Timestamps ✅ ❌ N/A

Installation

gem install debug_me

Or add to your Gemfile:

gem 'debug_me'

Requirements

  • Ruby >= 2.3.0
  • No external dependencies

License

Released under the MIT License.