Class: Loghandler::Rules::ThinAccessLogRule

Inherits:
AbstractRule show all
Defined in:
lib/loghandler/rules/thin_access_log_rule.rb

Instance Method Summary collapse

Methods inherited from AbstractRule

#match?

Constructor Details

#initialize(log_detail) ⇒ ThinAccessLogRule

Returns a new instance of ThinAccessLogRule.



5
6
7
# File 'lib/loghandler/rules/thin_access_log_rule.rb', line 5

def initialize(log_detail)
  @log_detail=log_detail
end

Instance Method Details

#apply!Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/loghandler/rules/thin_access_log_rule.rb', line 8

def apply!
  log_detail = {}
  tmp = CSV.parse(@log_detail[:content],col_sep:" ")
  tmp = tmp[0]
  log_detail[:ip] = tmp[0]
  log_detail[:date] = tmp[3]+tmp[4]
  log_detail[:url]=tmp[5]
  log_detail[:status]=tmp[6].to_i
  log_detail[:length]=tmp[7].to_i
  log_detail[:referer]=tmp[8]
  log_detail[:user_agent]=tmp[9]
  #p  [log_detail[:url],log_detail[:status]]
  @log_detail.merge!(log_detail)
  if @log_detail[:status]>=500
    @log_detail[:severity]="error"
  elsif @log_detail[:status]>=400
    @log_detail[:severity]="warning"
  else
    @log_detail[:severity]="none"
  end
end

#logObject



29
30
31
# File 'lib/loghandler/rules/thin_access_log_rule.rb', line 29

def log
 @log_detail.to_json
end

#loggable?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/loghandler/rules/thin_access_log_rule.rb', line 32

def loggable?
  true
end

#persist?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/loghandler/rules/thin_access_log_rule.rb', line 35

def persist?
  false
end

#showable?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/loghandler/rules/thin_access_log_rule.rb', line 38

def showable?
  true
end