Sha256: 3bf9be97b131346fb8f5f0b0bb0615ace5f7e4e3876b8bef1ff8d4b2d6c4b6ef

Contents?: true

Size: 517 Bytes

Versions: 2

Compression:

Stored size: 517 Bytes

Contents

require 'logger'

class PgExport
  class BuildLogger
    FORMATS = {
      plain: ->(_, _, _, message) { "#{message}\n" },
      muted: ->(_, _, _, _) {},
      timestamped: lambda do |severity, datetime, progname, message|
        "#{datetime} #{Process.pid} TID-#{Thread.current.object_id.to_s(36)}#{progname} #{severity}: #{message}\n"
      end
    }.freeze

    def self.call(stream:, format:)
      Logger.new(stream).tap do |logger|
        logger.formatter = FORMATS.fetch(format)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pg_export-0.6.1 lib/pg_export/build_logger.rb
pg_export-0.6.0 lib/pg_export/build_logger.rb