Module: HTTParty::Logger

Defined in:
lib/httparty/logger/logger.rb,
lib/httparty/logger/curl_formatter.rb,
lib/httparty/logger/apache_formatter.rb

Defined Under Namespace

Classes: ApacheFormatter, CurlFormatter

Class Method Summary collapse

Class Method Details

.add_formatter(name, formatter) ⇒ Object

Raises:


13
14
15
16
# File 'lib/httparty/logger/logger.rb', line 13

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

.build(logger, level, formatter) ⇒ Object


18
19
20
21
22
23
24
# File 'lib/httparty/logger/logger.rb', line 18

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

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

.formattersObject


6
7
8
9
10
11
# File 'lib/httparty/logger/logger.rb', line 6

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