Skip to content

Instantly share code, notes, and snippets.

@mikz
Created March 13, 2012 12:42
Show Gist options
  • Save mikz/af48839e7c9e1ac970c0 to your computer and use it in GitHub Desktop.
Save mikz/af48839e7c9e1ac970c0 to your computer and use it in GitHub Desktop.
class ActiveSupport::Callbacks::Callback
def should_run_callback_with_log?(*args)
should = should_run_callback_without_log?(*args)
if should
Rails.logger.info "++> \033[1;32m#{message(*args)}\033[0m"
else
Rails.logger.info "++> \033[1;37m#{message(*args)}\033[0m"
end
should
end
def message(*args)
object = args.first
msg = case method
when Symbol
[object.method(method).owner, method].join('::')
when String
method
when Proc
method.to_s
when Method
[metod.owner, method].join('::')
else
"unknown method #{method.inspect}"
end
"(#{object.class})--> #{msg}."
end
alias_method_chain :should_run_callback?, :log
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment