This gem provides classes for logging method's invocation start and finish using the amazing after_do gem. Theses classes are compatible with the interface defined by the after_do-loader gem.
Add this line to your application's Gemfile:
gem 'after_do-logging'
And then execute:
$ bundle
Or install it yourself as:
$ gem install after_do-logging
The first thing to do is tell AfterDo::Logging
which logger it should use by
setting the class variable AfterDo::Logging.logger
.
AfterDo::Logging.logger = logger
# or, if you use Rails
AfterDo::Logging.logger = Rails.logger
You can apply the logging callbacks using:
AfterDo::Logging::Aspect.new(MyClass).log_start(:method_to_log)
AfterDo::Logging::Aspect.new(MyClass).log_finish(:method_to_log)
This will log a message before and after invoking MyClass#method_to_log
.
Although, the best way to do this is by using after_do-loader
to apply the
callbacks in a dynamic and unobtrusive way. Configure your aspect to use
AfterDo::Logging::Aspect
or AfterDo::Logging::StateTransitionAspect
.
- Fork it ( https://github.com/stupied4ever/after_do-logging/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request