Module: Analytics::Loggers
- Included in:
- Analytics
- Defined in:
- lib/analytics_logger/analytics/loggers.rb
Overview
The logging methods associated with the analytics
Instance Method Summary collapse
-
#log(name, options = {}) ⇒ Object
options :level -> The log level of the event; e.g., AnalyticsEventType::INFO, AnalyticsEventType::AUDIT, AnalyticsEventType::WARNING, AnalyticsEventType::ERROR :user -> The user that was logged in when the event was triggered :params -> The params when the event was triggered :exception -> The exception that was encountered when the event was triggered Any has items that are not an explicitly defined option above, will be stuffed into the “additional_objects” column and stored in the DB.
-
#log_on_error(name, options = {}, &block) ⇒ Object
same as log, but allows a block, and will only log an event if the block raises an exception will re-throw the exception unless :throw => false is specified.
Instance Method Details
#log(name, options = {}) ⇒ Object
options
:level -> The log level of the event; e.g., AnalyticsEventType::INFO, AnalyticsEventType::AUDIT, AnalyticsEventType::WARNING, AnalyticsEventType::ERROR
:user -> The user that was logged in when the event was triggered
:params -> The params when the event was triggered
:exception -> The exception that was encountered when the event was triggered
Any has items that are not an explicitly defined option above, will be stuffed into the “additional_objects” column and stored in the DB
14 15 16 17 |
# File 'lib/analytics_logger/analytics/loggers.rb', line 14 def log(name, = {}) analytics_event = AnalyticsEvent.new(setup_log(name, )) analytics_event.save end |
#log_on_error(name, options = {}, &block) ⇒ Object
same as log, but allows a block, and will only log an event if the block raises an exception will re-throw the exception unless :throw => false is specified
36 37 38 39 40 41 42 43 44 |
# File 'lib/analytics_logger/analytics/loggers.rb', line 36 def log_on_error(name, = {}, &block) [:level] ||= AnalyticsEventType::ERROR # log as an error by default begin yield rescue self.log(name, ) raise unless [:throw] == false end end |