Module: HTTParty::Logger

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

Defined Under Namespace

Classes: ApacheFormatter, CurlFormatter, LogstashFormatter

Class Method Summary collapse

Class Method Details

.add_formatter(name, formatter) ⇒ Object

Raises:


15
16
17
18
# File 'lib/httparty/logger/logger.rb', line 15

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


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

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

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

.formattersObject


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

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