Class: LogTool::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/logtool/block.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#assetObject

Returns the value of attribute asset.



3
4
5
# File 'lib/logtool/block.rb', line 3

def asset
  @asset
end

#ipObject

Returns the value of attribute ip.



3
4
5
# File 'lib/logtool/block.rb', line 3

def ip
  @ip
end

#methodObject

Returns the value of attribute method.



3
4
5
# File 'lib/logtool/block.rb', line 3

def method
  @method
end

#responseObject

Returns the value of attribute response.



3
4
5
# File 'lib/logtool/block.rb', line 3

def response
  @response
end

#textObject

Returns the value of attribute text.



3
4
5
# File 'lib/logtool/block.rb', line 3

def text
  @text
end

#timeObject

Returns the value of attribute time.



3
4
5
# File 'lib/logtool/block.rb', line 3

def time
  @time
end

Class Method Details

.asset_tailObject



37
38
39
40
41
# File 'lib/logtool/block.rb', line 37

def self.asset_tail
  # $1 = response, $2 = time
  time = /\d+(ms|s)/
    /^Served asset [0-9a-zA-Z\/._]+ - (\d\d\d) .*? \((\d+ms)\)$/
end

.headObject



21
22
23
24
# File 'lib/logtool/block.rb', line 21

def self.head
  #$1 = method, $2 = IP
  /^Started (GET|POST|PUT|DELETE) ".+?" for (\d\d?\d?.\d\d?\d?.\d\d?\d?.\d\d?\d?) at .*$/
end

.head_2_3Object

old rails head



26
27
28
29
# File 'lib/logtool/block.rb', line 26

def self.head_2_3 # old rails head
  #$1 = IP, $2 = method
  /^Processing .+? \(for (\d\d?\d?.\d\d?\d?.\d\d?\d?.\d\d?\d?) at .*?(GET|POST|PUT|DELETE).*$/
end

.tailObject



31
32
33
34
35
# File 'lib/logtool/block.rb', line 31

def self.tail
  # $1 = response
  time = /\d+(ms|s)/
    /^Completed (\d\d\d) .+? in (\d+ms)$/
end

Instance Method Details

#headObject



13
14
15
# File 'lib/logtool/block.rb', line 13

def head
  @text.split("\n").first
end

#is_asset?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/logtool/block.rb', line 9

def is_asset?
  @asset
end

#tailObject



17
18
19
# File 'lib/logtool/block.rb', line 17

def tail
  @text.split("\n").last
end

#test_for(query) ⇒ Object



43
44
45
46
47
# File 'lib/logtool/block.rb', line 43

def test_for(query)
  eval query
rescue => e
  LogTool::fatal_error("Bad filter. #{e.message}")
end

#to_sObject



5
6
7
# File 'lib/logtool/block.rb', line 5

def to_s
  @text
end