Class: TaggedLogger::ClassSpecificLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/tagged_logger/tagged_logger.rb

Overview

class methods

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ ClassSpecificLogger

Returns a new instance of ClassSpecificLogger.



179
180
181
182
183
184
185
186
187
# File 'lib/tagged_logger/tagged_logger.rb', line 179

def initialize(klass)
  @klass = klass
  [:debug, :warn, :info, :error, :fatal].each do |level|
    blocks = TaggedLogger.blocks_for(level, klass)
    eigenclass.send(:define_method, level) do |msg|
      blocks.each { |(tag_alias, block)| block.call(level, tag_alias, msg) }
    end
  end    
end

Instance Method Details

#detachObject



189
190
191
192
193
# File 'lib/tagged_logger/tagged_logger.rb', line 189

def detach
  @klass.class_eval do
    @class_logger = nil
  end
end

#eigenclassObject



175
176
177
# File 'lib/tagged_logger/tagged_logger.rb', line 175

def eigenclass
  class <<self; self; end
end