Sha256: 56f61bc2fec70cf258419c379761bc6e338b52ae6304d1c0831343add4c3391e

Contents?: true

Size: 696 Bytes

Versions: 8

Compression:

Stored size: 696 Bytes

Contents

require "alephant/logger/json"

module Alephant
  module Logger
    class Base
      def initialize(drivers)
        @drivers = drivers

        unless drivers.any? { |driver| driver.is_a? Alephant::Logger::JSON }
          drivers << Alephant::Logger::JSON.new("app.log")
        end
      end

      def write(*args)
        self.<< *args
      end

      def method_missing(name, *args)
        drivers.each do |driver|
          driver.send(name, *args) if driver.respond_to? name
        end
      end

      def respond_to?(name)
        drivers.any? do |driver|
          driver.respond_to?(name) || super
        end
      end

      private

      attr_reader :drivers
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
alephant-logger-3.1.4 lib/alephant/logger/base.rb
alephant-logger-3.1.2 lib/alephant/logger/base.rb
alephant-logger-3.1.1 lib/alephant/logger/base.rb
alephant-logger-3.1.0 lib/alephant/logger/base.rb
alephant-logger-3.0.2 lib/alephant/logger/base.rb
alephant-logger-3.0.1 lib/alephant/logger/base.rb
alephant-logger-3.0.0 lib/alephant/logger/base.rb
alephant-logger-2.0.0 lib/alephant/logger/base.rb