lib/log_switch/mixin.rb in log_switch-0.3.0 vs lib/log_switch/mixin.rb in log_switch-0.4.0
- old
+ new
@@ -8,9 +8,20 @@
# @raise [RuntimeError] If {LogSwitch.extender} isn't set (which gets set
# when you +extend+ your class with {LogSwitch}).
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