From dfd34a59531c4ed8a5468c67b4ed02a00c5d89ee Mon Sep 17 00:00:00 2001 From: Slaven Rezic Date: Tue, 22 Aug 2017 15:48:52 +0200 Subject: [PATCH] adapt callback prepending for Log::Dispatch 2.59+ (RT #120329) Also remove special handling for newline option --- newer Log::Dispatch have this already built in. --- Makefile.PL | 2 +- lib/Log/Dispatch/Screen/Color.pm | 22 +++------------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 50ac9f6..55a63ee 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -2,7 +2,7 @@ use inc::Module::Install; name 'Log-Dispatch-Screen-Color'; all_from 'lib/Log/Dispatch/Screen/Color.pm'; -requires 'Log::Dispatch'; +requires 'Log::Dispatch' => 2.59; requires 'Term::ANSIColor'; requires 'Params::Validate'; requires 'Win32::Console::ANSI' if $^O eq 'MSWin32'; diff --git a/lib/Log/Dispatch/Screen/Color.pm b/lib/Log/Dispatch/Screen/Color.pm index b00c3c5..cc28c44 100644 --- a/lib/Log/Dispatch/Screen/Color.pm +++ b/lib/Log/Dispatch/Screen/Color.pm @@ -2,7 +2,7 @@ package Log::Dispatch::Screen::Color; use strict; use warnings; use base 'Log::Dispatch::Screen'; -our $VERSION = '0.04'; +our $VERSION = '0.04_50'; use Params::Validate qw(validate HASHREF BOOLEAN); Params::Validate::validation_options( allow_extra => 1 ); @@ -58,11 +58,6 @@ sub new { optional => 1, default => +{}, }, - newline => { - type => BOOLEAN, - optional => 1, - default => 0, - }, }); # generate color table @@ -77,14 +72,8 @@ sub new { } $self->{color} = $color; - # inject color callback - my @callbacks = $self->_get_callbacks(%p); - $self->{callbacks} = [ sub { $self->colored(@_) }, @callbacks ]; - - # newline - if ($p{newline}) { - push @{$self->{callbacks}}, \&_add_newline_callback; - } + # inject color callback XXX should use prepend_callback() which does not exist. See also https://rt.cpan.org/Ticket/Display.html?id=120329 + $self->{callbacks} = [ sub { $self->colored(@_) }, $self->{callbacks} ? @{ $self->{callbacks} } : () ]; $self; } @@ -115,11 +104,6 @@ sub colored { return $message; } -sub _add_newline_callback { - my %p = @_; - return $p{message} . "\n"; -} - 1; __END__ -- 2.7.4