Each line of a log exposes the raw line, but it also has method accessors for all the fields of the logged request.
The list of supported log line fields are listed in the S3 documentation: docs.amazonwebservices.com/AmazonS3/2006-03-01/LogFormat.html
line = log.lines.first line.remote_ip # => '72.21.206.5'
If a certain field does not apply to a given request (for example, the
key
field does not apply to a bucket request), or if it was
unknown or unavailable, it will return nil
.
line.operation # => 'REST.GET.BUCKET' line.key # => nil
Returns all fields of the line in a hash of the form :field_name
=> :field_value
.
line.attributes.values_at(:bucket, :key) # => ['marcel', 'kiss.jpg']
# File lib/aws/s3/logging.rb, line 200 def attributes self.class.fields.inject({}) do |attribute_hash, field| attribute_hash[field] = send(field) attribute_hash end end
# File lib/aws/s3/logging.rb, line 210 def parse scan(LINE_SCANNER).flatten.compact end