Class: DispatchRider::Logging::LifecycleLogger
- Inherits:
-
Object
- Object
- DispatchRider::Logging::LifecycleLogger
- Defined in:
- lib/dispatch-rider/logging/lifecycle_logger.rb
Class Method Summary collapse
- .log_error_handler_fail(message, exception) ⇒ Object
- .log_got_stop(reason, message) ⇒ Object
- .wrap_handling(message) ⇒ Object
Instance Method Summary collapse
-
#initialize(kind, message, options = {}) ⇒ LifecycleLogger
constructor
A new instance of LifecycleLogger.
- #log ⇒ Object
Constructor Details
#initialize(kind, message, options = {}) ⇒ LifecycleLogger
Returns a new instance of LifecycleLogger.
44 45 46 47 48 |
# File 'lib/dispatch-rider/logging/lifecycle_logger.rb', line 44 def initialize(kind, , = {}) @kind = kind @message = @options = end |
Class Method Details
.log_error_handler_fail(message, exception) ⇒ Object
5 6 7 |
# File 'lib/dispatch-rider/logging/lifecycle_logger.rb', line 5 def log_error_handler_fail(, exception) new(:error_handler_fail, , exception: exception).log end |
.log_got_stop(reason, message) ⇒ Object
9 10 11 |
# File 'lib/dispatch-rider/logging/lifecycle_logger.rb', line 9 def log_got_stop(reason, ) new(:stop, , reason: reason).log end |
.wrap_handling(message) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dispatch-rider/logging/lifecycle_logger.rb', line 13 def wrap_handling() start_time = Time.now log_start() yield log_success() rescue => exception log_fail(, exception) raise exception ensure log_complete(, Time.now - start_time) end |
Instance Method Details
#log ⇒ Object
50 51 52 |
# File 'lib/dispatch-rider/logging/lifecycle_logger.rb', line 50 def log logger.send(log_action, formatted_data) end |