Ravn::

LoggingTaskObserver class

A logging observer for Concurrent objects that implement the Observer interface, e.g., Concurrent::TimerTask.

Attributes

observable_name R

The name of the object being observed.

Public Class Methods

new( observable_name )

Create a new observer that will track the status of the given observable_name.

# File lib/ravn/logging_task_observer.rb, line 18
def initialize( observable_name )
        @observable_name = observable_name
end

Public Instance Methods

update( time, result, ex )

Concurrent::Observable API – update the status of the object being observed.

# File lib/ravn/logging_task_observer.rb, line 33
def update( time, result, ex )
        if ex&.is_a?( Concurrent::TimeoutError )
                self.log.warn "%s (%0.3f) Execution timed out" % [ self.observable_name, time ]
        elsif ex
                self.log.error "%s (%0.3f) Execution failed: %s" %
                        [ self.observable_name, time, ex.full_message(order: :bottom) ]
        else
                self.log.debug "%s (%0.3f) Execution successful; returned %p" %
                        [ self.observable_name, time, result ]
        end
end