Permalink
Browse files

turn off screen output by default when a filehandle is being used

  • Loading branch information...
1 parent c490738 commit 2fafdc79ac647f71631926a8797ac41ac7af3c41 @karenetheridge karenetheridge committed Mar 28, 2012
Showing with 11 additions and 3 deletions.
  1. +11 −3 lib/Pinto/Logger.pm
View
@@ -54,12 +54,20 @@ has log_level => (
},
);
-# optionally logs to this filehandle.
+# optionally logs to this filehandle
has filehandle => (
is => 'ro',
isa => IO,
alias => 'out', # for backcompat
coerce => 1,
+ predicate => '_has_filehandle',
+);
+
+has noscreen => (
+ is => 'ro',
+ isa => Bool,
+ lazy => 1,
+ default => sub { shift->_has_filehandle },
);
my %normal = ( text => undef, background => undef );
@@ -73,7 +81,7 @@ has logger => (
my $self = shift;
Log::Dispatch->new(
outputs => [
- [
+ ( $self->noscreen ? () : [
$self->nocolor ? 'Screen' : 'Screen::Color',
min_level => $self->log_level,
newline => 1,
@@ -87,7 +95,7 @@ has logger => (
emergency => \%bold_red,
fatal => \%bold_red,
)},
- ],
+ ]),
( $self->filehandle ? [
'Handle',
min_level => $self->log_level,

0 comments on commit 2fafdc7

Please sign in to comment.