blib/lib/Log/Dispatch/TestDiag.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 4 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 90.2% 37 / 41 CC 4 SCAR 6.4
CC
4
Cov
94%
new
3.0
log_message
2.0
BEGIN
1.0
CRAP 1.9
↑ Summary
1 package Log::Dispatch::TestDiag;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use base qw(Log::Dispatch::Output);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Test::More qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = '0.03';
9  
10 4 ▶sub new {
Subroutine new: called CC=3 SCAR=11.1
Pod documented
11 4 my $proto = shift;
12 4 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
040
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
13 4 my $self = bless { }, $class;
14 4 my %opts = @_;
15  
16 4 $self->_basic_init(%opts);
17  
18 4 ▶ $self->{as_note} = 1 if ($opts{as_note});
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"as_note"} 1 3 4
19  
20 4 return $self;
21 }
22  
23 4 ▶sub log_message {
Subroutine log_message: called CC=2 SCAR=6.9
Pod documented
24 4 my $self = shift;
25 4 my %p = @_;
26 $self->{as_note}
27 ? Test::More::note($p{message})
28 4 ▶ : Test::More::diag($p{message});
Branch: 1 branch
BranchTrueFalseTotal
$self->{'as_note'} ? : 2 2 4
29 }
30  
31 2 1;
32  
33 =head1 NAME
34  
35 Log::Dispatch::TestDiag - Log to Test::More's diagnostic output
36  
37 =head1 SYNOPSIS
38  
39 use Log::Dispatch;
40  
41 my $logger = Log::Dispatch->new(
42 outputs => [
43 ['TestDiag', min_level=>'debug', as_note=>0],
44 ],
45 );
46  
47 =head1 DESCRIPTION
48  
49 This module provides a C<Log::Dispatch> output that spits the logged records out
50 using C<Test::More>'s diagnostic output.
51  
52 =head1 METHODS
53  
54 =over
55  
56 =item new()
57  
58 Constructs a new C<Log::Dispatch::TestDiag> object and returns it to the caller.
59 Accepts standard C<Log::Dispatch::Output> parameters (e.g. C<min_level>).
60  
61 Also accepts an optional "C<as_note>" parameter, to indicate that output should
62 be sent via C<Test::More::note()> instead of C<Test::More::diag()>. Difference
63 is that a "note" only appears in the verbose TAP stream and does not get shown
64 when running under a test harness.
65  
66 =item log_message(%p)
67  
68 Logs the given message.
69  
70 =back
71  
72 =head1 AUTHOR
73  
74 Graham TerMarsch (cpan@howlingfrog.com)
75  
76 =head1 COPYRIGHT
77  
78 Copyright (C) 2011, Graham TerMarsch. All Rights Reserved.
79  
80 This is free software, you can redistribute it and/or modify it under the
81 Artistic-2.0 license.
82  
83 =head1 SEE ALSO
84  
85 =over
86  
87 =item L<Log::Dispatch>
88  
89 =back
90  
91 =cut
↑ Summary