Runops::Recorder::Reader - A class which can read the recording files
Instances of this class reads a recording. It can work both as a stream-based reader where you ask for the next entry or as a event generator that calls your handlers for each type of item it reads.
# main script use Runops::Recorder::Reader; my $reader = Runops::Recorder::Reader->read("my-recording", { handler => "MyRecordingHandler", }); $reader->read(); # MyRecordingHandler.pm package MyRecordingHandler; sub on_switch_file { my ($self, $id, $path) = @_; print "Now in file: $path\n"; } sub on_next_statement { my ($self, $line_no) = @_; print "Executing line: $line_no\n"; } 1;
Creates a new instance of this class. Takes $path which must be a path to a recording and an optional hashref with options. Valid options are
An package name or instance of a class which on which methods will be called when events occur. See "EVENTS"
A hashref with event/callback pairs that are called when events occur. See "EVENTS"
An boolean that indicates wheter keyframes should be skipped or not - ie, not generate an event or be returned from read_next
read_next
Reads the next entry in the recording and returns a list with the numeric event and its decoded contents. See "EVENTS"
Reads thru the recording generating events.
Reads the identifiers, files etc that we saw during recording
Reads all events until the next of of type $event occurs.
Returns the identifier with the given $id.
Searches for the next keyframe. This is to be used in the future when one can tail recordings being generated.
Decodes the blob $data according to the rules for the specific event and returns a list of values.
The following events may occur in the recording. They can be returned by read_next or cause a callback/method to be invoked.
The kind of events that can happen. Numeric code, constant and callback name within parenthesis for each item.
KEYFRAME
on_keyframe
A keyframe is an entry that we can wait for in tailing mode to know where we can start reading. These are inserted every 1024 events or so. No data/arguments.
SWITCH_FILE
on_switch_file
Happens when we execute a statement in another source file than the current one. No arguments.
NEXT_STATEMENT
on_next_statement
A statement has been executed. Data/argument is line number.
line number
DIE
on_die
The program threw an exception using die. No data/arguments.
die
ENTER_SUB
on_enter_sub
A subroutine was called. Data/arguments are identifier id and identifier.
identifier id
identifier
Nothing is exported by default. The tag events export the event constants listed about in "EVENTS".
To install Runops::Recorder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Runops::Recorder
CPAN shell
perl -MCPAN -e shell install Runops::Recorder
For more information on module installation, please visit the detailed CPAN module installation guide.