File Coverage

blib/lib/Log/Dispatch/Prowl.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Log::Dispatch::Prowl;
2             our $VERSION = '1.000';
3              
4              
5 1     1   19389 use strict;
  1         3  
  1         33  
6 1     1   5 use warnings;
  1         1  
  1         25  
7              
8 1     1   1361 use WebService::Prowl;
  0            
  0            
9              
10             use base qw( Log::Dispatch::Output );
11              
12             use Params::Validate qw(validate SCALAR);
13             Params::Validate::validation_options(allow_extra => 1);
14              
15             sub new {
16             my $proto = shift;
17             my $class = ref $proto || $proto;
18              
19             my %p = validate(
20             @_,
21             { apikey => { type => SCALAR },
22             name => { type => SCALAR }, });
23              
24             my $self = bless { apikey => $p{apikey} }, $class;
25              
26             $self->_basic_init(%p);
27              
28             return $self;
29             }
30              
31             my %map_level = (0 => -2, 1 => -2, 2 => -2, 3 => -1, 4 => 0, 5 => 1, 6 => 1, 7 => 2);
32              
33             sub log_message {
34             my $self = shift;
35             my %p = @_;
36              
37             my $ws = WebService::Prowl->new(apikey => $self->{apikey});
38              
39             my $level = $self->_level_as_number($p{level});
40             my $event = uc($self->_level_as_name($p{level}));
41              
42             $ws->add(
43             application => $p{name},
44             event => $event,
45             priority => $map_level{$level},
46             description => $p{message});
47             }
48              
49             1;
50              
51             __END__