Sha256: b79264363637e5e80e613972750844c9203310a9ef5113f0e802758ff8d924d5

Contents?: true

Size: 785 Bytes

Versions: 10

Compression:

Stored size: 785 Bytes

Contents

# encoding: UTF-8
require 'kafo/logging'

module Kafo
  class Logger

    attr_reader :logger, :name

    def initialize(name = 'root')
      @name = name
      @logger = (name == 'root') ? Logging.root_logger : Logging.add_logger(name)
    end

    def log(level, *args, &block)
      if Logging.buffering?
        if block_given?
          data = yield
        else
          data = args
        end

        Logging.to_buffer(@name, ::Logging::LogEvent.new(@name, ::Logging::LEVELS[level.to_s], data, false))
      else
        Logging.dump_buffer if Logging.dump_needed?
        @logger.send(level, *args, &block)
      end
    end

    Logging::LOG_LEVELS.each do |level|
      define_method(level) do |*args, &block|
        log(level, *args, &block)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kafo-7.6.0 lib/kafo/logger.rb
kafo-7.5.1 lib/kafo/logger.rb
kafo-7.5.0 lib/kafo/logger.rb
kafo-7.4.0 lib/kafo/logger.rb
kafo-7.3.0 lib/kafo/logger.rb
kafo-7.2.0 lib/kafo/logger.rb
kafo-7.1.0 lib/kafo/logger.rb
kafo-7.0.0 lib/kafo/logger.rb
kafo-6.5.0 lib/kafo/logger.rb
kafo-6.4.1 lib/kafo/logger.rb