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.
Learn more about puts_debuggerer over here: https://github.com/AndyObtiva/puts_debuggerer
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| Rails.logger.info(output)}
It defaults to
:puts
, but if Rails is detected, it defaults to: lambda {|output| Rails.logger.debug(output)}
Example:
# 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
No comments:
Post a Comment