Class: Dreamcatcher::Monitor
- Inherits:
-
Object
- Object
- Dreamcatcher::Monitor
- Defined in:
- lib/dreamcatcher/monitor.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Instance Method Summary collapse
-
#initialize(configuration) ⇒ Monitor
constructor
A new instance of Monitor.
- #monitor(options = {}, &block) ⇒ Object
Constructor Details
#initialize(configuration) ⇒ Monitor
Returns a new instance of Monitor.
5 6 7 8 |
# File 'lib/dreamcatcher/monitor.rb', line 5 def initialize(configuration) @configuration = configuration @handlers = build_handlers end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
3 4 5 |
# File 'lib/dreamcatcher/monitor.rb', line 3 def configuration @configuration end |
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
3 4 5 |
# File 'lib/dreamcatcher/monitor.rb', line 3 def handlers @handlers end |
Instance Method Details
#monitor(options = {}, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/dreamcatcher/monitor.rb', line 10 def monitor( = {}, &block) @context = [:context] || {} logger_proxy = Dreamcatcher::LoggerProxy.new([:logger]) logger_proxy.capture { block.call } rescue @configuration.exception_class => exception context = Dreamcatcher::ExceptionContext.new(exception, logger_proxy.log_entries, @context) handlers.each { |handler| handler.handle_exception(context) } raise end |