Sha256: b6d93c0120249171f2cf7a036207375d6da54c543a1be2b74e03d551f834e5dc

Contents?: true

Size: 634 Bytes

Versions: 12

Compression:

Stored size: 634 Bytes

Contents

module Spacebunny
  # Log on multiple outputs at the same time
  #
  # Usage example:
  #
  # log_file = File.open("log/debug.log", "a")
  # Logger.new Spacebunny::Logger.new(STDOUT, log_file)

  class Logger
    def initialize(*args)
      @streams = []
      args.each do |a|
        case a
          when String
            # This is a file path
            @streams << File.open(a, 'a+')
          else
            @streams << a
        end
      end
    end

    def write(*args)
      @streams.each do |lo|
        lo.write(*args)
        lo.flush
      end
    end

    def close
      @streams.each(&:close)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
spacebunny-4.2.0 lib/spacebunny/logger.rb
spacebunny-4.1.1 lib/spacebunny/logger.rb
spacebunny-4.1.0 lib/spacebunny/logger.rb
spacebunny-4.0.0 lib/spacebunny/logger.rb
spacebunny-3.0.0 lib/spacebunny/logger.rb
spacebunny-2.0.0 lib/spacebunny/logger.rb
spacebunny-1.5.1 lib/spacebunny/logger.rb
spacebunny-1.5.0 lib/spacebunny/logger.rb
spacebunny-1.4.0 lib/spacebunny/logger.rb
spacebunny-1.3.0 lib/spacebunny/logger.rb
spacebunny-1.2.2 lib/spacebunny/logger.rb
spacebunny-1.2.1 lib/spacebunny/logger.rb