Class: MySQLLogLine

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

Overview

MySQL Parsing is broken

Constant Summary collapse

DISCARD =
Regexp.new("(^Time )|(^Tcp)|( Quit )|( USE )|(Connect)")
START_QUERY =
Regexp.new('\d{1,5} Query')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ MySQLLogLine

Returns a new instance of MySQLLogLine.



122
123
124
125
126
127
128
129
130
131
132
# File 'lib/pqa.rb', line 122

def initialize(text)
  @recognized = true
  @is_new_query = false
  if DISCARD.match(text) != nil
    @recognized = false
    return
  end
  @text = text
  @is_new_query = START_QUERY.match(@text) != nil

end

Instance Attribute Details

#is_new_queryObject (readonly)

Returns the value of attribute is_new_query.



120
121
122
# File 'lib/pqa.rb', line 120

def is_new_query
  @is_new_query
end

#recognizedObject (readonly)

Returns the value of attribute recognized.



120
121
122
# File 'lib/pqa.rb', line 120

def recognized
  @recognized
end

#textObject (readonly)

Returns the value of attribute text.



120
121
122
# File 'lib/pqa.rb', line 120

def text
  @text
end

Instance Method Details

#is_continuationObject



134
135
136
# File 'lib/pqa.rb', line 134

def is_continuation
  @recognized && !/^(\d{1,6})|(\s*)/.match(@text).nil?
end

#is_duration_lineObject



138
139
140
# File 'lib/pqa.rb', line 138

def is_duration_line
  false
end

#parse_query_segmentObject



142
143
144
145
146
147
148
149
# File 'lib/pqa.rb', line 142

def parse_query_segment
  if @is_new_query
    tmp = START_QUERY.match(@text.strip)
    raise StandardError.new("PQA identified a line as the start of a new query, but then was unable to match it with the START_QUERY Regex. #{BUG_URL_STRING}") if tmp == nil
    return tmp.post_match.strip
  end
  @text.strip.chomp
end

#to_sObject



151
152
153
# File 'lib/pqa.rb', line 151

def to_s
  @text
end