class Fluent::ApacheLogFormat
Public Class Methods
# File lib/fluent/plugin/out_alf.rb, line 25 def initialize super end
Public Instance Methods
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 => ''
# File lib/fluent/plugin/out_alf.rb, line 21 def configure(conf) super end
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
# File lib/fluent/plugin/out_alf.rb, line 33 def shutdown super end
# File lib/fluent/plugin/out_alf.rb, line 29 def start super end
Private Instance Methods
# 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