Class: Ralf::ClfTranslator

Inherits:
Object
  • Object
show all
Defined in:
lib/ralf/clf_translator.rb

Constant Summary collapse

AMAZON_LOG_FORMAT =
Regexp.new('([^ ]*) ([^ ]*) \[([^\]]*)\] ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) "([^"]*)" ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) "([^"]*)" "([^"]*)"')
AMAZON_LOG_COPY_FORMAT =
Regexp.new('([^ ]*) ([^ ]*) \[([^\]]*)\] ([^ ]*) ([^ ]*) ([^ ]*) (REST.COPY.OBJECT_GET) ([^ ]*) (-) ([^ ]*) (-) (-) ([^ ]*) (-) (-) (-) (-) (-)')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line, options = {}) ⇒ ClfTranslator

options:

:recalculate_partial_content => false (default)
  If request is '206 Partial Content' estimate the actual bytes when apparent bandwidth has exceeded 2Mbit/sec.
  S3 caches content to edge servers with a burst which never reaches the client


15
16
17
18
19
20
# File 'lib/ralf/clf_translator.rb', line 15

def initialize(line, options = {})
  @options = options
  @error = false
  @line = line
  @translate_successfull = translate
end

Instance Attribute Details

#bucketObject (readonly)

Returns the value of attribute bucket.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def bucket
  @bucket
end

#bytes_sentObject (readonly)

Returns the value of attribute bytes_sent.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def bytes_sent
  @bytes_sent
end

#durationObject (readonly)

Returns the value of attribute duration.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def duration
  @duration
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def http_status
  @http_status
end

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def key
  @key
end

#lineObject (readonly)

Returns the value of attribute line.



6
7
8
# File 'lib/ralf/clf_translator.rb', line 6

def line
  @line
end

#object_sizeObject (readonly)

Returns the value of attribute object_size.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def object_size
  @object_size
end

#operationObject (readonly)

Returns the value of attribute operation.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def operation
  @operation
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/ralf/clf_translator.rb', line 8

def options
  @options
end

#ownerObject (readonly)

Returns the value of attribute owner.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def owner
  @owner
end

#referrerObject (readonly)

Returns the value of attribute referrer.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def referrer
  @referrer
end

#remote_ipObject (readonly)

Returns the value of attribute remote_ip.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def remote_ip
  @remote_ip
end

#request_idObject (readonly)

Returns the value of attribute request_id.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def request_id
  @request_id
end

#request_uriObject (readonly)

Returns the value of attribute request_uri.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def request_uri
  @request_uri
end

#request_version_idObject (readonly)

Returns the value of attribute request_version_id.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def request_version_id
  @request_version_id
end

#s3_error_codeObject (readonly)

Returns the value of attribute s3_error_code.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def s3_error_code
  @s3_error_code
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def timestamp
  @timestamp
end

#total_time_in_msObject (readonly)

Returns the value of attribute total_time_in_ms.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def total_time_in_ms
  @total_time_in_ms
end

#turn_around_time_in_msObject (readonly)

Returns the value of attribute turn_around_time_in_ms.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def turn_around_time_in_ms
  @turn_around_time_in_ms
end

#user_agentObject (readonly)

Returns the value of attribute user_agent.



7
8
9
# File 'lib/ralf/clf_translator.rb', line 7

def user_agent
  @user_agent
end

Instance Method Details

#to_sObject



22
23
24
25
26
27
28
# File 'lib/ralf/clf_translator.rb', line 22

def to_s
  if @translate_successfull
    "%s - %s [%s] \"%s\" %s %s \"%s\" \"%s\" %d" % [remote_ip, requester, timestamp, request_uri, http_status, bytes_sent, referrer, user_agent, duration]
  else
    nil
  end
end