Class: ValidationRage::LogNotifier
- Inherits:
-
BaseNotifier
- Object
- BaseNotifier
- ValidationRage::LogNotifier
- Defined in:
- lib/validation_rage/log_notifier.rb
Instance Attribute Summary collapse
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
-
#call(event_name, payload) ⇒ Object
TODO: optimize log format.
-
#initialize(args) ⇒ LogNotifier
constructor
A new instance of LogNotifier.
Methods inherited from BaseNotifier
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_level ⇒ Object
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 |
#logger ⇒ Object
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 |