Class: LogMagic::MySqlRefiner

Inherits:
BaseRefiner show all
Defined in:
lib/log_magic/refiners/mysql_refiner.rb

Instance Attribute Summary

Attributes inherited from BaseRefiner

#lines

Instance Method Summary collapse

Methods inherited from BaseRefiner

#initialize, #matches?, #persistance_layer

Constructor Details

This class inherits a constructor from LogMagic::BaseRefiner

Instance Method Details

#computeObject



6
7
8
9
10
# File 'lib/log_magic/refiners/mysql_refiner.rb', line 6

def compute
  mysql_query = extract_mysql_query
  persist_mysql_query(mysql_query)
  output(mysql_query, persistance_layer.uuid)
end

#extract_mysql_queryObject



17
18
19
# File 'lib/log_magic/refiners/mysql_refiner.rb', line 17

def extract_mysql_query
  @lines.last.match(load_sql_regex)[1]
end

#line_match_regexObject



2
3
4
# File 'lib/log_magic/refiners/mysql_refiner.rb', line 2

def line_match_regex
  /\w*\sLoad/
end

#load_sql_regexObject



25
26
27
# File 'lib/log_magic/refiners/mysql_refiner.rb', line 25

def load_sql_regex
  /Load \([\d\.]+ms\)[^S]*(.*)/
end

#output(mysql_query, uuid) ⇒ Object



12
13
14
15
# File 'lib/log_magic/refiners/mysql_refiner.rb', line 12

def output(mysql_query, uuid)
  mysql_printer = ::LogMagic::MySqlPrinter.new(mysql_query, uuid)
  mysql_printer.print
end

#persist_mysql_query(mysql_query) ⇒ Object



21
22
23
# File 'lib/log_magic/refiners/mysql_refiner.rb', line 21

def persist_mysql_query(mysql_query)
  persistance_layer.add_value('mysql_query', mysql_query)
end