Skip to content

Instantly share code, notes, and snippets.

@clicube
Created November 23, 2014 20:56
Show Gist options
  • Save clicube/cb3a4176a76ede008620 to your computer and use it in GitHub Desktop.
Save clicube/cb3a4176a76ede008620 to your computer and use it in GitHub Desktop.
printfデバッグの出力が目立たないので赤くする
lambda{
header = lambda{|color| "\e[#{color}m" }
footer = lambda{ "\e[0m" }
add = lambda{|name|
dname = ("d" + name.to_s).to_sym
Kernel.send :define_method, dname do |*args|
begin
print header.call(31)
puts "(#{caller(1)[0]})"
Kernel.send name, *args
rescue => e
e.backtrace.shift
raise e
ensure
print footer.call
end
end
}
add.call :puts
add.call :p
add.call :pp
}.call
if $0 == __FILE__
dputs "nyan"
dp [*(1..10)]
dpp [*(1..10)]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment