Skip to content
Browse files

Removed prepare_message option since this is supported by Log::Handle…

…r itself already
  • Loading branch information...
1 parent 8a5575b commit 2b04ff5c5c6f25cd66fab44f984c7e152617403b @plu committed Nov 9, 2009
Showing with 6 additions and 47 deletions.
  1. +2 −0 Changes
  2. +0 −8 README
  3. +0 −19 lib/Log/Handler/Output/Gearman.pm
  4. +4 −20 t/01-validate.t
View
2 Changes
@@ -3,6 +3,8 @@ Revision history for Log-Handler-Output-Gearman
0.01003 Thu Nov 06 2009
- New method reload() (supported since Log::Handler 0.62)
- New method gearman_client(), returns Gearman::XS::Client instance
+ - Removed prepare_message option since this is supported by Log::Handler
+ itself already
0.01002 Thu Jul 16 2009
- Adapt error handling of other Log::Handler::Output modules
View
8 README
@@ -50,14 +50,6 @@ METHODS
* "do_high_background"
* "do_low_background"
- * prepare_message
-
- # encode log message before it's being sent as workload to Gearman
- prepare_message => sub {
- my ($message) = @_;
- return JSON::XS::encode({ message => $message });
- }
-
log
Takes one argument:
View
19 lib/Log/Handler/Output/Gearman.pm
@@ -87,16 +87,6 @@ This can be one of the following L<Gearman::XS::Client> methods:
=back
-=item *
-
-prepare_message
-
- # encode log message before it's being sent as workload to Gearman
- prepare_message => sub {
- my ($message) = @_;
- return JSON::XS::encode({ message => $message });
- }
-
=back
=cut
@@ -136,14 +126,9 @@ sub log {
my $method = $self->{method};
my $worker = $self->{worker};
- my $prepare = $self->{prepare_message};
my $workload = $message;
- if ( ref($prepare) eq 'CODE' ) {
- $workload = $prepare->($message);
- }
-
my ( $ret, $job_handle ) = $self->{client}->$method( $worker, $workload );
if ( $ret != GEARMAN_SUCCESS ) {
return $self->_raise_error( $self->{client}->error() );
@@ -229,10 +214,6 @@ sub _validate {
regex => qr/^(do|do_high|do_low|do_background|do_high_background|do_low_background)$/,
default => 'do_background',
},
- prepare_message => {
- type => Params::Validate::CODEREF,
- optional => 1,
- },
}
);
}
View
24 t/01-validate.t
@@ -2,7 +2,7 @@ use strict;
use warnings;
use Log::Handler;
use Log::Handler::Output::Gearman;
-use Test::More tests => 7;
+use Test::More tests => 6;
eval { my $logger = Log::Handler::Output::Gearman->new(); };
@@ -28,20 +28,6 @@ qr/The 'servers' parameter \("invalid"\) to Log::Handler::Output::Gearman::.*? w
'Invalid servers parameter'
);
-eval {
- my $logger = Log::Handler::Output::Gearman->new(
- servers => ['127.0.0.1:1234'],
- worker => 'logger',
- prepare_message => 'invalid'
- );
-};
-
-like(
- $@,
-qr/The 'prepare_message' parameter \("invalid"\) to Log::Handler::Output::Gearman::.*? was a 'scalar', which is not one of the allowed types: coderef/,
- 'Invalid prepare_message parameter'
-);
-
{
my $logger = Log::Handler::Output::Gearman->new(
servers => ['127.0.0.1:991233123'],
@@ -53,18 +39,16 @@ qr/The 'prepare_message' parameter \("invalid"\) to Log::Handler::Output::Gearma
{
my $logger = Log::Handler->new();
- my $gearman = Log::Handler::Output::Gearman->new(
+ my %handler_options = (
servers => ['127.0.0.1:991233123'],
worker => 'logger',
- );
- my %handler_options = (
maxlevel => 'warning',
minlevel => 'critical',
timeformat => '%Y-%m-%d %H:%M:%S',
message_layout => '%T [%L] [%P] %m (%X)',
die_on_errors => 0,
);
- $logger->add( $gearman => \%handler_options );
+ $logger->add( gearman => \%handler_options );
my $error = '';
unless ($logger->critical('test123')) {
$error = $logger->errstr();
@@ -73,7 +57,7 @@ qr/The 'prepare_message' parameter \("invalid"\) to Log::Handler::Output::Gearma
my $dying_logger = Log::Handler->new();
$handler_options{die_on_errors} = 1;
- $dying_logger->add($gearman => \%handler_options);
+ $dying_logger->add(gearman => \%handler_options);
eval {
$dying_logger->critical('test123');
};

0 comments on commit 2b04ff5

Please sign in to comment.
Something went wrong with that request. Please try again.