Class: WasTracer::TraceLine
- Inherits:
-
Object
- Object
- WasTracer::TraceLine
- Defined in:
- lib/was_tracer/trace_line.rb
Constant Summary collapse
- BASE_YEAR =
2000
- PARSE_REGEX =
/ \[(\d{1,2})\/(\d{1,2})\/(\d{2})\s # dd-mm-yy 1, 2, 3 (\d{1,2}):(\d{1,2}):(\d{1,2}):(\d{3})\s # hh-mm-ss-uuu 4, 5, 6, 7 \w{3}\]\s* ([\w]{8})\s* # threadid 8 ([^\s]*)\s* # traceid 9 (.)\s* # kind 10 (.*)$ # data 11 /x
- METHOD_REGEX =
/ ([^\s\(]*)\s* # class name 1 (.*)\s* # method name 2 (ENTRY|RETURN)\s* (.*)$ # params 4 /x
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#line ⇒ Object
Returns the value of attribute line.
-
#line_number ⇒ Object
Returns the value of attribute line_number.
-
#thread_id ⇒ Object
Returns the value of attribute thread_id.
-
#time ⇒ Object
Returns the value of attribute time.
-
#time_str ⇒ Object
Returns the value of attribute time_str.
-
#trace_name ⇒ Object
Returns the value of attribute trace_name.
Class Method Summary collapse
Instance Method Summary collapse
- #entering? ⇒ Boolean
- #exiting? ⇒ Boolean
-
#initialize(file_data, line, line_number) ⇒ TraceLine
constructor
A new instance of TraceLine.
- #method_name ⇒ Object
- #method_params ⇒ Object
Constructor Details
#initialize(file_data, line, line_number) ⇒ TraceLine
Returns a new instance of TraceLine.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/was_tracer/trace_line.rb', line 28 def initialize(file_data, line, line_number) @time = Time.mktime(BASE_YEAR + file_data[2].to_i, file_data[0], file_data[1], file_data[3], file_data[4], file_data[5], file_data[6].to_i * 1000) @time_str = "#{file_data[3]}:#{file_data[4]}:#{file_data[5]}:#{file_data[6]}" @thread_id = file_data[7] @trace_name = file_data[8] @kind = file_data[9] @data = file_data[10] @line = line @line_number = line_number end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
26 27 28 |
# File 'lib/was_tracer/trace_line.rb', line 26 def data @data end |
#kind ⇒ Object
Returns the value of attribute kind.
26 27 28 |
# File 'lib/was_tracer/trace_line.rb', line 26 def kind @kind end |
#line ⇒ Object
Returns the value of attribute line.
26 27 28 |
# File 'lib/was_tracer/trace_line.rb', line 26 def line @line end |
#line_number ⇒ Object
Returns the value of attribute line_number.
26 27 28 |
# File 'lib/was_tracer/trace_line.rb', line 26 def line_number @line_number end |
#thread_id ⇒ Object
Returns the value of attribute thread_id.
26 27 28 |
# File 'lib/was_tracer/trace_line.rb', line 26 def thread_id @thread_id end |
#time ⇒ Object
Returns the value of attribute time.
26 27 28 |
# File 'lib/was_tracer/trace_line.rb', line 26 def time @time end |
#time_str ⇒ Object
Returns the value of attribute time_str.
26 27 28 |
# File 'lib/was_tracer/trace_line.rb', line 26 def time_str @time_str end |
#trace_name ⇒ Object
Returns the value of attribute trace_name.
26 27 28 |
# File 'lib/was_tracer/trace_line.rb', line 26 def trace_name @trace_name end |
Class Method Details
.from_line(line, line_number) ⇒ Object
21 22 23 24 |
# File 'lib/was_tracer/trace_line.rb', line 21 def self.from_line(line, line_number) match_group = line.chomp.match PARSE_REGEX TraceLine.new(match_group.captures, line, line_number) if match_group end |
Instance Method Details
#entering? ⇒ Boolean
65 66 67 |
# File 'lib/was_tracer/trace_line.rb', line 65 def entering? @kind == '>' end |
#exiting? ⇒ Boolean
69 70 71 |
# File 'lib/was_tracer/trace_line.rb', line 69 def exiting? @kind == '<' end |
#method_name ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/was_tracer/trace_line.rb', line 40 def method_name return @data unless entering? or exiting? return @method_name if @method_name m = @data.match METHOD_REGEX @method_params = m[4] if m[2] =~ /^\(/ @method_name = "#{m[1]}()" else @method_name = "#{m[1]}.#{m[2]}()" end end |
#method_params ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/was_tracer/trace_line.rb', line 52 def method_params return '' unless entering? or exiting? return @method_params if @method_params m = @data.match METHOD_REGEX if m[2] =~ /^\(/ @method_name = "#{m[1]}()" else @method_name = "#{m[1]}.#{m[2]}()" end @method_params = m[4] end |