Sha256: 9375fde38e0f7f50b830e9bf4ecf3b232915a5837d3d7b714b5f07ac7ee72c35

Contents?: true

Size: 826 Bytes

Versions: 87

Compression:

Stored size: 826 Bytes

Contents

# frozen_string_literal: true

require 'httparty/logger/apache_formatter'
require 'httparty/logger/curl_formatter'
require 'httparty/logger/logstash_formatter'

module HTTParty
  module Logger
    def self.formatters
      @formatters ||= {
        :curl => Logger::CurlFormatter,
        :apache => Logger::ApacheFormatter,
        :logstash => Logger::LogstashFormatter,
      }
    end

    def self.add_formatter(name, formatter)
      raise HTTParty::Error.new("Log Formatter with name #{name} already exists") if formatters.include?(name)
      formatters.merge!(name.to_sym => formatter)
    end

    def self.build(logger, level, formatter)
      level ||= :info
      formatter ||= :apache

      logger_klass = formatters[formatter] || Logger::ApacheFormatter
      logger_klass.new(logger, level)
    end
  end
end

Version data entries

87 entries across 86 versions & 4 rubygems

Version Path
harbr-0.1.61 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.60 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.59 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.58 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.57 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.56 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.55 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.54 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.53 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.52 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.50 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.49 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.48 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.47 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.46 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.45 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.44 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.43 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.42 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb
harbr-0.1.41 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/logger/logger.rb