Module: Roby::DRoby::EventLogging

Included in:
ExecutionEngine, Plan
Defined in:
lib/roby/droby/event_logging.rb

Overview

Mixin to add event-logging related functionality to a class

The class must provide a #event_logger object. It must be non-nil, and can be initialized with NullEventLogger for a no-op logger

Instance Method Summary collapse

Instance Method Details

#log(m, *args) ⇒ Object

Log an event on the underlying logger



9
10
11
# File 'lib/roby/droby/event_logging.rb', line 9

def log(m, *args)
    event_logger.dump(m, Time.now, args)
end

#log_flush_cycle(m, *args) ⇒ Object



50
51
52
# File 'lib/roby/droby/event_logging.rb', line 50

def log_flush_cycle(m, *args)
    event_logger.flush_cycle(m, Time.now, args)
end

#log_queue_sizeObject

The amount of cycles pending in the #event_logger‘s dump queue



46
47
48
# File 'lib/roby/droby/event_logging.rb', line 46

def log_queue_size
    event_logger.log_queue_size
end

#log_timepoint(name) ⇒ Object

Log a timepoint on the underlying logger



14
15
16
17
# File 'lib/roby/droby/event_logging.rb', line 14

def log_timepoint(name)
    current_thread = Thread.current
    event_logger.dump_timepoint(:timepoint, Time.now, [current_thread.droby_id, current_thread.name, name])
end

#log_timepoint_group(name) ⇒ Object

Run a block within a timepoint group



20
21
22
23
24
25
# File 'lib/roby/droby/event_logging.rb', line 20

def log_timepoint_group(name)
    log_timepoint_group_start(name)
    yield
ensure
    log_timepoint_group_end(name)
end

#log_timepoint_group_end(name) ⇒ Object

End a timepoint group

The logger will NOT do any validation of the group start/end pairing at logging time. This is done at replay time



40
41
42
43
# File 'lib/roby/droby/event_logging.rb', line 40

def log_timepoint_group_end(name)
    current_thread = Thread.current
    event_logger.dump_timepoint(:timepoint_group_end, Time.now, [current_thread.droby_id, current_thread.name, name])
end

#log_timepoint_group_start(name) ⇒ Object

Log a timepoint on the underlying logger

The logger will NOT do any validation of the group start/end pairing at logging time. This is done at replay time



31
32
33
34
# File 'lib/roby/droby/event_logging.rb', line 31

def log_timepoint_group_start(name)
    current_thread = Thread.current
    event_logger.dump_timepoint(:timepoint_group_start, Time.now, [current_thread.droby_id, current_thread.name, name])
end