38 lines
1.2 KiB
Perl
38 lines
1.2 KiB
Perl
package Polyze::H2Early;
|
|
use Moose;
|
|
use Polyze::HCount;
|
|
use Polyze::H2Late;
|
|
with 'Polyze::Handler';
|
|
|
|
sub scan_line {
|
|
my ($self, $line) = @_;
|
|
my $is_past_early_lines = $line->text =~ $self->day_regex;
|
|
return do {
|
|
if (! $is_past_early_lines) {
|
|
# No point in looking at this line any further.
|
|
$Polyze::NEXT_LINE;
|
|
} else {
|
|
# Inform the polyze object that we did find the wanted day.
|
|
$self->polyze->is_day_found(1);
|
|
# Since log lines are ordered by timestamp, our work is done.
|
|
$self->polyze->remove_handler($self);
|
|
# Add a handler to detect going past date. Put it ahead of the
|
|
# other handlers so that it can switch off current-day handlers
|
|
# promptly.
|
|
$self->polyze->unshift_handler(
|
|
Polyze::H2Late->new(polyze => $self->polyze),
|
|
);
|
|
# We're not returning REDO so this won't count this first in-day line.
|
|
# But that's OK because the count initialises to 1.
|
|
$self->polyze->push_handler(
|
|
Polyze::HCount->new(polyze => $self->polyze),
|
|
);
|
|
# Now let the regular handlers do their things.
|
|
$Polyze::CONTINUE_LINE;
|
|
}
|
|
};
|
|
}
|
|
|
|
no Moose;
|
|
__PACKAGE__->meta->make_immutable;
|