Class: EffectiveLogger
- Inherits:
-
Object
- Object
- EffectiveLogger
- Defined in:
- app/models/effective_logger.rb
Overview
Call EffectiveLog.info or EffectiveLog.success EffectiveLog.error
Class Method Summary collapse
Class Method Details
.log(message, status = EffectiveLogging.statuses.first, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/models/effective_logger.rb', line 4 def self.log(, status = EffectiveLogging.statuses.first, = {}) if [:user].present? && ![:user].kind_of?(User) raise ArgumentError.new("Log.log :user => ... argument must be a User object") end if [:parent].present? && ![:parent].kind_of?(Effective::Log) raise ArgumentError.new("Log.log :parent => ... argument must be an Effective::Log object") end if [:associated].present? && ![:associated].kind_of?(ActiveRecord::Base) raise ArgumentError.new("Log.log :associated => ... argument must be an ActiveRecord::Base object") end Effective::Log.new().tap do |log| log. = log.status = status log.user_id = .delete(:user_id) log.user = .delete(:user) log.parent = .delete(:parent) log.associated = .delete(:associated) log.details = .delete_if { |k, v| v.blank? } if .kind_of?(Hash) log.save end end |