class Fluent::ApacheLogFormat

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_alf.rb, line 25
def initialize
  super
end

Public Instance Methods

configure(conf) click to toggle source

TODO: Add params to allow different field names for the log ā€œ%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %Dā€ config_param :host, :string config_param :time, :string config_param :method, :string config_param :path, :string config_param :status, :string config_param :size, :integer, :default => 0 config_param :referer, :string, :default => '' config_param :user_agent, :string, :default => '' config_param :response_time, :integer, :default => ''

Calls superclass method
# File lib/fluent/plugin/out_alf.rb, line 21
def configure(conf)
  super
end
emit(tag, es, chain) click to toggle source

This method is called when an event reaches Fluentd. 'es' is a Fluent::EventStream object that includes multiple events. You can use 'es.each {|time,record| … }' to retrieve events. 'chain' is an object that manages transactions. Call 'chain.next' at appropriate points and rollback if it raises an exception.

NOTE! This method is called by Fluentd's main thread so you should not write slow routine here. It causes Fluentd's performance degression.

# File lib/fluent/plugin/out_alf.rb, line 44
def emit(tag, es, chain)
  chain.next
  es.each {|time,record|
    puts output_record(record)
  }

end
shutdown() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_alf.rb, line 33
def shutdown
  super
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_alf.rb, line 29
def start
  super
end

Private Instance Methods

output_record(record) click to toggle source
# File lib/fluent/plugin/out_alf.rb, line 54
def output_record(record)
  "#{record['ip']} - - [#{DateTime.parse(record['timestamp']).strftime("%d/%b/%Y:%H:%M:%S %z")}] \"#{record['method']} #{record['path'].empty? ? '/' : record['path']}\" #{record['status']} 1024 \"#{record['referer']}\" \"#{record['user_agent']}\" #{record['measuretime']}"
end