Class: LogMonitor::Factory

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

Class Method Summary collapse

Class Method Details

.get(config) ⇒ Object



6
7
8
9
10
11
# File 'lib/log_monitor.rb', line 6

def self.get(config)
  alerter = self.get_alerter(config)
  alerter.set_in(config['monitor']['target'])
  alerter.set_words(config['monitor']['words'])
  alerter
end

.get_alerter(config) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/log_monitor.rb', line 13

def self.get_alerter(config)
  if config['method'] == 'email'
    alerter = LogMonitor::EmailAlerter.new
    alerter.set_email(config['email'])
  elsif config['method'] == 'webpost'
    alerter = LogMonitor::WebPostAlerter.new
    alerter.set_webpost(config['webpost'])
  elsif config['method'] == 'file'
    alerter = LogMonitor::FileAlerter.new
    alerter.set_out(config['file'])
  else
    alerter = LogMonitor::Alerter.new
  end
  alerter
end