Skip to content

Commit

Permalink
add print option mainly for command line
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Oct 29, 2013
1 parent a9252d6 commit 252fcd5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ requires 'parent';
requires 'YAML::Tiny';
requires 'perl', '5.008001';

recommends 'PerlIO::Util';

suggests 'Fluent::Logger';

on configure => sub {
Expand Down
7 changes: 6 additions & 1 deletion lib/App/RunCron.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use Sys::Hostname;

use Class::Accessor::Lite (
new => 1,
ro => [qw/timestamp command reporter error_reporter common_reporter tag/],
ro => [qw/timestamp command reporter error_reporter common_reporter tag print/],
rw => [qw/logfile logpos exit_code _finished/],
);

Expand Down Expand Up @@ -82,8 +82,13 @@ sub _run {
}
else {
close $logwh;
if ($self->print) {
require PerlIO::Util;
$self->_logfh->push_layer(tee => *STDOUT);
}
$self->_log($_) while <$logrh>;
close $logrh;
$self->_logfh->pop_layer if $self->print;
while (wait == -1) {}
$self->exit_code($?);
}
Expand Down
1 change: 1 addition & 0 deletions lib/App/RunCron/CLI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ sub new {
$p->getoptions(\my %opt, qw/
logfile=s
timestamp
print
reporter=s
error_reporter=s
common_reporter=s
Expand Down

0 comments on commit 252fcd5

Please sign in to comment.