-
-
Save mikz/af48839e7c9e1ac970c0 to your computer and use it in GitHub Desktop.
This file contains 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 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