Sha256: e1da85ac5a984990b814fbc5e5bb72845b41addacc5dc538aa80a81a3fe98e05

Contents?: true

Size: 953 Bytes

Versions: 2

Compression:

Stored size: 953 Bytes

Contents

# frozen_string_literals: true

module Lumberjack
  class Device
    # This is a logging device that forward log entries to multiple other devices.
    class Multi < Device
      def initialize(*devices)
        @devices = devices
      end
      
      def write(entry)
        @devices.each do |device|
          device.write(entry)
        end
      end
      
      def flush
        @devices.each do |device|
          device.flush
        end
      end
      
      def close
        @devices.each do |device|
          device.close
        end
      end
      
      def reopen(logdev = nil)
        @devices.each do |device|
          device.reopen(logdev = nil)
        end
      end
      
      def datetime_format
        @devices.detect(&:datetime_format).datetime_format
      end
      
      def datetime_format=(format)
        @devices.each do |device|
          device.datetime_format = format
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lumberjack-1.1.1 lib/lumberjack/device/multi.rb
lumberjack-1.1.0 lib/lumberjack/device/multi.rb