Saturday, November 25, 2017

puts_debuggerer 0.8.0 is out!

puts_debuggerer, the library for improved Ruby puts debugging, now has better support for Rails.

In a Rails environment, puts_debuggerer now automatically outputs to Rails logs at the debug level. This is facilitated using the new "printer" support, which is a configurable option that comes with smart defaults.

The "printer" option value can be a global method symbol or lambda expression to use in printing to the user. Examples of global methods are :puts and :print. An example of a lambda expression is lambda {|output|}
It defaults to :puts , but if Rails is detected, it defaults to: lambda {|output| Rails.logger.debug(output)}
# File Name: /Users/User/example.rb
PutsDebuggerer.printer = lambda {|output| Rails.logger.error(output)}
str = "Hello"
pd str
Prints out in the Rails app log as error lines:
[PD] /Users/User/example.rb:5
   > pd str
  => Hello

Learn more about puts_debuggerer over here:

No comments: