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



11
12
13
# File 'lib/roby/droby/event_logging.rb', line 11

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

#log_flush_cycle(m, *args) ⇒ Object



69
70
71
# File 'lib/roby/droby/event_logging.rb', line 69

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



65
66
67
# File 'lib/roby/droby/event_logging.rb', line 65

def log_queue_size
    event_logger.log_queue_size
end

#log_timepoint(name) ⇒ Object

Log a timepoint on the underlying logger



16
17
18
19
20
21
22
23
24
# File 'lib/roby/droby/event_logging.rb', line 16

def log_timepoint(name)
    return unless event_logger.log_timepoints?

    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



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

def log_timepoint_group(name)
    return yield unless event_logger.log_timepoints?

    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



54
55
56
57
58
59
60
61
62
# File 'lib/roby/droby/event_logging.rb', line 54

def log_timepoint_group_end(name)
    return unless event_logger.log_timepoints?

    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



40
41
42
43
44
45
46
47
48
# File 'lib/roby/droby/event_logging.rb', line 40

def log_timepoint_group_start(name)
    return unless event_logger.log_timepoints?

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