Socket
Book a DemoInstallSign in
Socket

rails_dt

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rails_dt

1.2.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Ruby/Rails debug toolkit

rails_dt gem gives you the DT.p() method to print debug messages.

Usage

In your Gemfile, add:

gem "rails_dt", "git: https://github.com/dadooda/rails_dt.git"

Now, in your code, do something like:

DT.p "checkpoint 1"
DT.p "user", user

Debug messages are printed to:

  • Rails.logger in Rails mode (auto-detected);
  • STDERR in non-Rails mode;
  • log/dt.log if log/ exists in project root and is writable.

This is often handy:

$ tail -f log/dt.log

The ideas behind it

  • Debug message printer must not require initialization.
  • Debug message printer must be nothing else, but a debug message printer.
  • Debug message printer must be invoked the same way regardless of place of invocation.
  • Debug message printer calls must be clearly visible in code.
  • Debug message printer must print its location in code so you can easily remove the call once debugging is over.

A few out-of-the-box implementations review

Let me check a few popular out-of-the box implementation used by many of developers against "the ideas" items listed above.

Rails.logger:

  • Fail. It only works in Rails. Rails requires initialization.
  • (!) Fail. Logger is a production facility.
  • So-so. It's not possible to use Rails logger to debug parts of Rails itself.
  • (!) Fail. Debugging logger calls look the same as production logger calls.
  • Fail. Location in code is not printed.

Kernel::p:

  • OK.
  • OK.
  • OK.
  • So-so. p calls hide well among lines of meaningful code and it isn't always easy to spot them.
  • Fail. Location in code is not printed.

Cheers!

Feedback of any kind is greatly appreciated.

— Alex Fortuna, © 2010-2017

FAQs

Package last updated on 23 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.