Module: LoggerJsonCore

Defined in:
lib/core/logger_json_core.rb

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/core/logger_json_core.rb', line 2

def self.included(klass)
  %w{debug info warn error fatal}.each do |level|
    klass.send(:alias_method, "old_#{level}", level)

    block = Proc.new do |*args, &block|
      create_file args, level
      return send("old_#{level}", args[0]) { block.call } unless block.nil?
      send "old_#{level}", args[0]
    end

    klass.send(:define_method, level, block)
  end
end