Created
January 4, 2013 13:13
-
-
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)
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
@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