Module: LogSwitch::Mixin
- Defined in:
- lib/log_switch/mixin.rb
Class Method Summary collapse
-
.included(klass) ⇒ Object
When this module is included, this method gets called and defines a
#log
method on the including class.
Class Method Details
.included(klass) ⇒ Object
When this module is included, this method gets called and defines a #log
method on the including class.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/log_switch/mixin.rb', line 10 def self.included(klass) if LogSwitch.extender klass.send :define_method, :log do |*args| if LogSwitch.extender.log_class_name? && LogSwitch.extender.logger.class == Logger if args.size == 1 args = "<#{klass}> #{args.join}" else msg = args.delete_at 0 args.unshift("<#{klass}> #{msg}") end end LogSwitch.extender.log *args end else raise "No class has been extended by LogSwitch yet." end end |