
Security News
NIST Under Federal Audit for NVD Processing Backlog and Delays
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
When debugging in Ruby, print statements are still often the best tool for the job. But how many times have you found yourself typing stuff like this over and over?
def main
puts "========= in main"
movie_dirs.each do |movie_dir|
Find.find(movie_dir) do |fn|
if fn.is_movie?
parent_dir = File.dirname(fn)
movie = nil
if movie_dirs.include? parent_dir or parent_dir.has_another_movie(fn)
puts "========= in if movie_dirs..."
movie = get_movie fn
puts "========= movie: #{movie.inspect}"
else
movie = get_movie(fn, true)
end
.......
What if you could just do this instead?
def main
D.bg
movie_dirs.each do |movie_dir|
Find.find(movie_dir) do |fn|
if fn.is_movie?
parent_dir = File.dirname(fn)
movie = nil
if movie_dirs.include? parent_dir or parent_dir.has_another_movie(fn)
movie = get_movie fn
D.bg{'movie'}
else
movie = get_movie(fn, true)
end
.......
Now you can.
In your Gemfile, add:
gem 'quick-debug'
or run this, then require the gem as such:
$ gem install quick-debug
require 'quick-debug'
For especially legacy/hostile environments, or if you want to use this really quickly, you can directly require the quick-debug.rb
file in your code - it has no dependencies. If you do this often, a symlink could come in really useful. For example:
$ sudo ln -s /Library/Ruby/Gems/1.8/gems/quick-debug-0.0.1/lib/quick-debug.rb /quick-debug.rb
Then, from within your code:
require '/quick-debug'
def main
D.bg
movie_dirs.each do |movie_dir|
....
D.bg{'@somevar'}
Prints [<caller filename, method, and line number>] @somevar ~> <contents of @somevar.inspect>
to STDOUT. Any object can be passed in, but it must be surrounded by quotes or be made a symbol. If the block is omitted, only the caller method and line number will be printed.
D.lg{'@somevar'}
Same as above, but prints to /tmp/quick-debug.txt
instead. A short timestamp is also printed at the start of each line. To change the output filepath, do
D.logpath = '</some/path/log.txt>'
D.str{'@somevar'}
The above methods just return the deubg output as a string, rather than printing them anywhere. This can be very useful if you need to use your own logging framework, for example: logger.debug D.str{'@somevar'}
.
D.disable :bg
prevents all D.bg
statements from printing anything. You can also pass in :lg
or :all
to disable D.lg
statements or just everything respectively. You can use
D.enable
to re-enable them. It accepts the same options.
D.bg(:force){'@somevar'}
D.lg(:force){'@somevar'}
The debug methods accept a :force
argument, which will cause those calls to run even though that output location been disabled.
FAQs
Unknown package
We found that quick-debug demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.
Security News
TypeScript Native Previews offers a 10x faster Go-based compiler, now available on npm for public testing with early editor and language support.