Created
December 9, 2015 16:22
-
-
Save kyontan/ac82cf115690d367897d to your computer and use it in GitHub Desktop.
STDOUT にも同時に吐いてくれる Logger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Logger | |
alias_method :add_old, :add | |
remove_method :add, :log | |
def method_missing(method_name, *args, &block) | |
if /^log|add$/ === method_name | |
puts "#{(args[1] && args[1] + ": ") || ""}#{args[2]}" | |
self.send(:add_old, *args, &block) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment