Class: Pacproxy::AccessLogger

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/pacproxy/access_logger.rb

Overview

Provide log Function

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAccessLogger

Returns a new instance of AccessLogger.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pacproxy/access_logger.rb', line 12

def initialize
  c = Config.instance.config['access_log']
  @format = WEBrick::AccessLog::COMMON_LOG_FORMAT
  return @logger = nil unless c

  @format = c['format'] if c['format']

  location = c['location'] ? c['location'] : STDOUT
  shift_age = c['shift_age'] ? c['shift_age'] : 0
  shift_size = c['shift_size'] ? c['shift_size'] : 1_048_576
  @logger = Logger.new(location, shift_age, shift_size)
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/pacproxy/access_logger.rb', line 10

def logger
  @logger
end

Instance Method Details

#accesslog(req, res) ⇒ Object



25
26
27
28
29
30
# File 'lib/pacproxy/access_logger.rb', line 25

def accesslog(req, res)
  params = setup_params(req, res)
  return unless @logger
  @logger << WEBrick::AccessLog.format(@format, params)
  @logger << "\n"
end