Module: Roby::EventLogging::Mixin
- Included in:
- Roby::ExecutionEngine, Plan
- Defined in:
- lib/roby/event_logging/mixin.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
-
#log(name, *args) ⇒ Object
Log an event.
-
#log_flush_cycle(name, *args) ⇒ Object
Announce the last event of a cycle.
-
#log_queue_size ⇒ Object
The amount of cycles pending in the #event_logger's dump queue.
-
#log_timepoint(name) ⇒ Object
Log a timepoint.
-
#log_timepoint_group(name) ⇒ Object
Log a timepoint group.
-
#log_timepoint_group_end(name) ⇒ Object
End a timepoint group.
-
#log_timepoint_group_start(name) ⇒ Object
Start a timepoint group.
Instance Method Details
#log(name, *args) ⇒ Object
Log an event
Events are logged with a name, a timestamp and arbitrary arguments
13 14 15 |
# File 'lib/roby/event_logging/mixin.rb', line 13 def log(name, *args) event_logger.dump(name, Time.now, args) end |
#log_flush_cycle(name, *args) ⇒ Object
Announce the last event of a cycle
This is used for loggers that are cycle-based (e.g. the DRobyEventLogger) so that it adds the given event and then save the whole cycle to I/O
102 103 104 |
# File 'lib/roby/event_logging/mixin.rb', line 102 def log_flush_cycle(name, *args) event_logger.flush_cycle(name, Time.now, args) end |
#log_queue_size ⇒ Object
The amount of cycles pending in the #event_logger's dump queue
94 95 96 |
# File 'lib/roby/event_logging/mixin.rb', line 94 def log_queue_size event_logger.log_queue_size end |
#log_timepoint(name) ⇒ Object
Log a timepoint
Timepoints are saved as :timepoint events, with a timestamp, a reference on the thread that generated the timepoint and the timepoint name
22 23 24 25 26 27 28 29 30 |
# File 'lib/roby/event_logging/mixin.rb', line 22 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
Log a timepoint group
Timepoint groups are zones of code that are gated with two timepoints, a start timepoint #name_start and an end timepoint (#name_end). This is used during analysis to show duration of blocks of code.
This method will emit the start timepoint, yield and then emit the end timepoint
42 43 44 45 46 47 48 49 |
# File 'lib/roby/event_logging/mixin.rb', line 42 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
Timepoint groups are zones of code that are gated with two timepoints, a start timepoint #name_start and an end timepoint (#name_end). This is used during analysis to show duration of blocks of code.
This emits the start timepoint. Client code is expected to ensure proper pairing, the runtime code won't do any validation. Validation is only performed at replay time
83 84 85 86 87 88 89 90 91 |
# File 'lib/roby/event_logging/mixin.rb', line 83 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
Start a timepoint group
Timepoint groups are zones of code that are gated with two timepoints, a start timepoint #name_start and an end timepoint (#name_end). This is used during analysis to show duration of blocks of code.
This emits the start timepoint. Client code is expected to ensure proper pairing, the runtime code won't do any validation. Validation is only performed at replay time
62 63 64 65 66 67 68 69 70 |
# File 'lib/roby/event_logging/mixin.rb', line 62 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 |