class Fluent::Debuggable
WOW! WHAT A FUCKING META PROGRAMMING!
Public Class Methods
extend_configure(klass)
click to toggle source
# File lib/fluent/plugin/in_debug.rb, line 42 def self.extend_configure(klass) unless klass.method_defined?(:configure_without_debug) klass.config_param :debug, :bool, :default => false klass.__send__(:alias_method, :configure_without_debug, :configure) klass.__send__(:define_method, :configure_with_debug) do |conf| configure_without_debug(conf) Debuggable.extend_emit(self) if conf['debug'] end klass.__send__(:alias_method, :configure, :configure_with_debug) end end
extend_emit(obj)
click to toggle source
# File lib/fluent/plugin/in_debug.rb, line 28 def self.extend_emit(obj) klass = obj.singleton_class unless klass.method_defined?(:emit_without_debug) klass.__send__(:alias_method, :emit_without_debug, :emit) klass.__send__(:define_method, :emit_with_debug) do |tag, es, chain| es.each do |time, record| $log.write "#{Time.at(time).localtime} #{tag}: #{Yajl.dump(record)}\n" end emit_without_debug(tag, es, chain) end klass.__send__(:alias_method, :emit, :emit_with_debug) end end