App-JobLog
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/JobLog/Log.pm view on Meta::CPAN
package App::JobLog::Log;
$App::JobLog::Log::VERSION = '1.042';
# ABSTRACT: the code that lets us interact with the log
use Modern::Perl;
use App::JobLog::Config qw(log init_file);
use App::JobLog::Log::Line;
use IO::All -utf8;
use autouse 'Carp' => qw(carp);
use autouse 'App::JobLog::Time' => qw(now);
use Class::Autouse qw(
App::JobLog::Log::Event
App::JobLog::Log::Note
DateTime
FileHandle
);
no if $] >= 5.018, warnings => "experimental::smartmatch";
# some stuff useful for searching log
use constant WINDOW => 30;
use constant LOW_LIM => 1 / 10;
use constant HIGH_LIM => 1 - LOW_LIM;
# some indices
use constant IO => 0;
use constant FIRST_EVENT => 1;
use constant LAST_EVENT => 2;
use constant FIRST_INDEX => 3;
use constant LAST_INDEX => 4;
# timestamp format
use constant TS => '%Y/%m/%d';
sub new {
my $class = shift;
$class = ref $class if ref $class;
# touch log into existence
unless ( -e log ) {
init_file log;
my $fh = FileHandle->new( log, 'w' );
$fh->close;
}
# using an array to make things a little snappier
my $self = bless [], $class;
$self->[IO] = io log;
return $self;
}
sub lines {
[ shift->[IO]->getlines ];
}
sub all_taglines {
my ($self) = @_;
# reopen log in sequential reading mode
$self->[IO] = io log;
my (@lines);
while ( my $line = $self->[IO]->getline ) {
my $ll = App::JobLog::Log::Line->parse($line);
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.210 second using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )