Skip to content

Instantly share code, notes, and snippets.

@kyontan
Created December 9, 2015 16:22
Show Gist options
  • Save kyontan/ac82cf115690d367897d to your computer and use it in GitHub Desktop.
Save kyontan/ac82cf115690d367897d to your computer and use it in GitHub Desktop.
STDOUT にも同時に吐いてくれる Logger
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