File Coverage

blib/lib/Log/Dispatch/TestDiag.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition 1 3 33.3
subroutine 6 6 100.0
pod 2 2 100.0
total 29 31 93.5


line stmt bran cond sub pod time code
1             package Log::Dispatch::TestDiag;
2              
3 1     1   103186 use strict;
  1         3  
  1         49  
4 1     1   6 use warnings;
  1         2  
  1         40  
5 1     1   5 use base qw(Log::Dispatch::Output);
  1         7  
  1         3391  
6 1     1   1786 use Test::More qw();
  1         2  
  1         288  
7              
8             our $VERSION = '0.01';
9              
10             sub new {
11 3     3 1 1181 my $proto = shift;
12 3   33     17 my $class = ref($proto) || $proto;
13 3         10 my $self = bless { }, $class;
14 3         21 $self->_basic_init(@_);
15 3         358 return $self;
16             }
17              
18             sub log_message {
19 2     2 1 394 my $self = shift;
20 2         7 my %p = @_;
21 2         7 Test::More::diag($p{message});
22             }
23              
24             1;
25              
26             =head1 NAME
27              
28             Log::Dispatch::TestDiag - Log to Test::More's diagnostic output
29              
30             =head1 SYNOPSIS
31              
32             use Log::Dispatch;
33              
34             my $logger = Log::Dispatch->new(
35             outputs => [
36             ['TestDiag', min_level=>'debug'],
37             ],
38             );
39              
40             =head1 DESCRIPTION
41              
42             This module provides a C<Log::Dispatch> output that spits the logged records out
43             using C<Test::More>'s diagnostic output.
44              
45             =head1 METHODS
46              
47             =over
48              
49             =item new()
50              
51             Constructs a new C<Log::Dispatch::TestDiag> object and returns it to the caller.
52             Accepts standard C<Log::Dispatch::Output> parameters (e.g. C<min_level>).
53              
54             =item log_message(%p)
55              
56             Logs the given message to C<Test::More::diag()>.
57              
58             =back
59              
60             =head1 AUTHOR
61              
62             Graham TerMarsch (cpan@howlingfrog.com)
63              
64             =head1 COPYRIGHT
65              
66             Copyright (C) 2011, Graham TerMArsch. All Rights Reserved.
67              
68             This is free software, you can redistribute it and/or modify it under the
69             Artistic-2.0 license.
70              
71             =head1 SEE ALSO
72              
73             L<Log::Dispatch>.
74              
75             =cut