Skip to content

Instantly share code, notes, and snippets.

@zsoldosp
Created January 4, 2013 13:13
Show Gist options
  • Save zsoldosp/4452506 to your computer and use it in GitHub Desktop.
Save zsoldosp/4452506 to your computer and use it in GitHub Desktop.
explicit logging vs. aop solutions (re: http://www.robustsoftware.co.uk/post/39211594225/logging)
@explained # adding it by AOP at startup or by codegen or whatever
def transient_condition(self, user)
character = random_character
return user.first_name.start_with?(random_character), "Checking if first_name:#{user.first_name} starts with character:#{character}"
end
def explained(wrapped, *args, **kwargs):
log.info('entering %s with params %s, %s' % (wrapped.__name__, args, kwargs))
result, explanation = wrapped(*args, **kwargs)
log.info('exiting %s with params %s, %s - return value is %s because %s' % (wrapped.__name, args, kwargs, result, explanation))
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment