Skip to content

Instantly share code, notes, and snippets.

@mirakui
Created December 7, 2011 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirakui/1443041 to your computer and use it in GitHub Desktop.
Save mirakui/1443041 to your computer and use it in GitHub Desktop.
puts with format
[STDOUT, STDERR].each do |io|
io.instance_eval do
def puts_with_format(*arg)
print "[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")} ##{$$}] "
puts_without_format *arg
end
alias puts_without_format puts
alias puts puts_with_format
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment