Class: ValidationRage::LogNotifier

Inherits:
BaseNotifier show all
Defined in:
lib/validation_rage/log_notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseNotifier

#data_present?, #subscribe!

Constructor Details

#initialize(args) ⇒ LogNotifier

Returns a new instance of LogNotifier.



4
5
6
7
# File 'lib/validation_rage/log_notifier.rb', line 4

def initialize(args)
  self.logger     = args[:logger]
  self.log_level  = args[:log_level]  || :warn
end

Instance Attribute Details

#log_levelObject

Returns the value of attribute log_level.



3
4
5
# File 'lib/validation_rage/log_notifier.rb', line 3

def log_level
  @log_level
end

#loggerObject

Returns the value of attribute logger.



3
4
5
# File 'lib/validation_rage/log_notifier.rb', line 3

def logger
  @logger
end

Instance Method Details

#call(event_name, payload) ⇒ Object

TODO: optimize log format



9
10
11
12
# File 'lib/validation_rage/log_notifier.rb', line 9

def call(event_name, payload)
  return if payload.values.first && payload.values.first.empty?
  self.logger.send(self.log_level, "#{event_name} #{payload}")
end