Class: LogMagic::BaseExplainer

Inherits:
Object
  • Object
show all
Includes:
JSONUtils, TemplatingUtils
Defined in:
lib/log_magic/explainers/base_explainer.rb

Direct Known Subclasses

MySqlExplainer, SearchkickExplainer

Instance Method Summary collapse

Methods included from TemplatingUtils

#enriche, #match_regex, #rendered_template, #template_dir, #template_name, #template_path

Methods included from JSONUtils

#parse_json, #pretty_print_json, #query_hash

Constructor Details

#initializeBaseExplainer

Returns a new instance of BaseExplainer.



5
6
7
# File 'lib/log_magic/explainers/base_explainer.rb', line 5

def initialize
  @persistance_layer = ::LogMagic::PersistanceLayer.new
end

Instance Method Details

#startObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/log_magic/explainers/base_explainer.rb', line 10

def start
  app = Proc.new do |env|
    @uuid = env['PATH_INFO'][1..-1]
    body = rendered_template

    ['200', {'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s}, [body]]
  end

  Rack::Handler::WEBrick.run app, Port: self.class.port_number,
                                  Logger: WEBrick::Log::new('/tmp/log_magic.log')
end