Sha256: 3559903742171d01d91b6e1bd5df27bd803108788f9ad58647c8558daf9a5ce2

Contents?: true

Size: 752 Bytes

Versions: 2

Compression:

Stored size: 752 Bytes

Contents

class PgExport
  module Logging
    FORMAT_PLAIN = ->(_, _, _, message) { "#{message}\n" }
    FORMAT_TIMESTAMPED = ->(severity, datetime, progname, message) { "#{datetime} #{Process.pid} TID-#{Thread.current.object_id.to_s(36)}#{progname} #{severity}: #{message}\n" }
    FORMAT_MUTED = ->(_, _, _, _) {}

    class << self
      def logger
        @logger ||= Logger.new(STDOUT).tap do |logger|
          logger.formatter = FORMAT_PLAIN
        end
      end

      def format_default
        logger.formatter = FORMAT_PLAIN
      end

      def format_timestamped
        logger.formatter = FORMAT_TIMESTAMPED
      end

      def mute
        logger.formatter = FORMAT_MUTED
      end
    end

    def logger
      Logging.logger
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pg_export-0.5.1 lib/pg_export/includable_modules/logging.rb
pg_export-0.5.0 lib/pg_export/includable_modules/logging.rb