Sha256: 14db9db80aff242cd30b7a05f6a702840959075d09bf7513237920a95b74573a

Contents?: true

Size: 463 Bytes

Versions: 1

Compression:

Stored size: 463 Bytes

Contents

# frozen_string_literal: true

module SeaShanty
  class Logger
    attr_reader :destination

    def initialize(destination)
      @destination = if destination.respond_to? :printf
        destination
      else
        File.open(destination.to_s, "a+")
      end
    end

    def log(message)
      destination.write(message)
      destination.write("\n") unless message.end_with?("\n")
    end

    class NullLogger
      def log(*)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sea_shanty-0.2.0 lib/sea_shanty/util/logger.rb