aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/logger.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/logger.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/logger.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/logger.rb b/activesupport/lib/active_support/core_ext/logger.rb
new file mode 100644
index 0000000000..9c1fd274ac
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/logger.rb
@@ -0,0 +1,16 @@
+# Adds the 'around_level' method to Logger.
+
+class Logger
+ def self.define_around_helper(level)
+ module_eval <<-end_eval
+ def around_#{level}(before_message, after_message, &block)
+ self.#{level}(before_message)
+ return_value = block.call(self)
+ self.#{level}(after_message)
+ return return_value
+ end
+ end_eval
+ end
+ [:debug, :info, :error, :fatal].each {|level| define_around_helper(level) }
+
+end \ No newline at end of file