Class: TreasureData::FileReader::ApacheParser

Inherits:
Object
  • Object
show all
Includes:
RegexpParserMixin
Defined in:
lib/td/file_reader.rb

Overview

ApacheParser and SyslogParser is a port of old table:import’s parsers

Constant Summary collapse

COLUMNS =

1.8 don’t have named capture, so need column names.

['host', 'user', 'time', 'method', 'path', 'code', 'size', 'referer', 'agent']
TIME_FORMAT =
"%d/%b/%Y:%H:%M:%S %z"

Instance Method Summary collapse

Methods included from RegexpParserMixin

#forward

Constructor Details

#initialize(reader, error, opts) ⇒ ApacheParser

Returns a new instance of ApacheParser.



168
169
170
171
172
173
174
# File 'lib/td/file_reader.rb', line 168

def initialize(reader, error, opts)
  super

  # e.g. 127.0.0.1 - - [23/Oct/2011:08:20:01 -0700] "GET / HTTP/1.0" 200 492 "-" "Wget/1.12 (linux-gnu)"
  @format = 'apache'
  @regexp = /^([^ ]*) [^ ]* ([^ ]*) \[([^\]]*)\] "(\S+)(?: +([^ ]*) +\S*)?" ([^ ]*) ([^ ]*)(?: "([^\"]*)" "([^\"]*)")?$/
end