Skip to content

Instantly share code, notes, and snippets.

@timruffles
Created May 25, 2011 10:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save timruffles/990749 to your computer and use it in GitHub Desktop.
Save timruffles/990749 to your computer and use it in GitHub Desktop.
extreme aop logging idea
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