-
-
Save craigw/990758 to your computer and use it in GitHub Desktop.
extreme aop logging idea
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
before: | |
def process_message message | |
logger.debug "Started #{message.headers["message-id"]}" | |
event = JSON.parse message.body | |
logger.debug "Action: #{event['action']}" | |
match_id = event['matchID'] | |
active_entries = PassingGame::Entry.count_active_for match_id | |
logger.info "#{active_entries} active entries for match_id = #{match_id}" | |
if fail_on? event | |
fail_entries_for match_id | |
else | |
give_points_to_entries_for match_id | |
end | |
logger.debug "Finished #{message.headers["message-id"]}" | |
end | |
after: | |
log do | |
process_message do | |
before { "Started #{message.headers["message-id"]}" } | |
after { "Finished #{message.headers["message-id"]}" } | |
method ['PassingGame::Entry','count_active_for'], :after, lambda { "#{active_entries} active entries for match_id = #{match_id}" } | |
method ['JSON','parse'], :after, lambda { logger.debug "Action: #{event['action']}" } | |
end | |
end | |
def process_message message | |
event = JSON.parse message.body | |
match_id = event['matchID'] | |
active_entries = PassingGame::Entry.count_active_for match_id | |
if fail_on? event | |
fail_entries_for match_id | |
else | |
give_points_to_entries_for match_id | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment