Log4perl.pm

filter: Statementstmt 28.9% 33 / 114 Branchbran 0.0% 0 / 50 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 34.7% 8 / 23 Podpod 100% 4 / 4 totaltotal 21.4% 45 / 210 CC 30 SCAR 34.2
CC
30
Cov
19%
_dbix_l4p_debug
90.0
_dbix_l4p_error
42.0
_dbix_l4p_warning
30.0
CRAP 30.4
« Log4perl/st.pm ↑ Summary Log4perl/Constants.pm »
1 # $Id: Log4perl.pm 279 2006-09-01 18:36:01Z martin $
2 2 require 5.008;
3  
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Carp qw(croak cluck);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Log::Log4perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 package DBIx::Log4perl;
11 2 ▶use DBIx::Log4perl::Constants qw (:masks $LogMask);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use DBIx::Log4perl::db;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use DBIx::Log4perl::st;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 our $VERSION = '0.26';
16 2 require Exporter;
17 2 our @ISA = qw(Exporter DBI); # look in DBI for anything we don't do
18  
19 2 our @EXPORT = (); # export nothing by default
20 2 our @EXPORT_MASKS = qw(DBIX_L4P_LOG_DEFAULT
21 DBIX_L4P_LOG_ALL
22 DBIX_L4P_LOG_INPUT
23 DBIX_L4P_LOG_OUTPUT
24 DBIX_L4P_LOG_CONNECT
25 DBIX_L4P_LOG_TXN
26 DBIX_L4P_LOG_ERRCAPTURE
27 DBIX_L4P_LOG_WARNINGS
28 DBIX_L4P_LOG_ERRORS
29 DBIX_L4P_LOG_DBDSPECIFIC
30 DBIX_L4P_LOG_DELAYBINDPARAM
31 DBIX_L4P_LOG_SQL
32 );
33 2 our %EXPORT_TAGS= (masks => \@EXPORT_MASKS);
34 2 Exporter::export_ok_tags('masks'); # all tags must be in EXPORT_OK
35  
36 0 ▶sub _dbix_l4p_debug {
Subroutine _dbix_l4p_debug: not called CC=9 SCAR=45.0
37 0 my ($self, $h, $level, $thing, @args) = @_;
38  
39 0 ▶ $h = $self->{private_DBIx_Log4perl} if !defined($h);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $h 0 0 0
40  
41 0 ▶ return unless $h->{logger}->is_debug();
Branch: 1 branch
BranchTrueFalseTotal
unless $h->{"logger"}->is_debug 0 0 0
42  
43 0 local $Data::Dumper::Indent = 0;
44 0 local $Data::Dumper::Quotekeys = 0;
45  
46 0 ▶ local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + $level
Branch: 1 branch
BranchTrueFalseTotal
if $level 0 0 0
47 if $level;
48  
49 0 ▶ if (scalar(@args) > 1) {
Branch: 4 branches
BranchTrueFalseTotal
if (scalar @args > 1) { } 0 0 0
elsif (ref $thing eq 'CODE') { } 0 0 0
elsif (ref $args[0]) { } 0 0 0
elsif (scalar @args == 1) { } 0 0 0
50 $h->{logger}->debug(
51 0 ▶ sub {Data::Dumper->Dump([\@args], [$thing])})
Subroutine __ANON__: not called CC=1 SCAR=6.9
52 0 } elsif (ref($thing) eq 'CODE') {
53 0 $h->{logger}->debug($thing);
54 } elsif (ref($args[0])) {
55 $h->{logger}->debug(
56 0 ▶ sub {Data::Dumper->Dump([$args[0]], [$thing])})
Subroutine __ANON__: not called CC=1 SCAR=6.9
57 0 } elsif (scalar(@args) == 1) {
58 0 ▶ if (!defined($args[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $args[0]) { } 0 0 0
59 0 $h->{logger}->debug("$thing:");
60 } else {
61 0 $h->{logger}->debug("$thing: " . DBI::neat($args[0]));
62 }
63 } else {
64 0 $h->{logger}->debug($thing);
65 }
66 0 return;
67 }
68  
69 0 ▶sub _dbix_l4p_info {
Subroutine _dbix_l4p_info: not called CC=3 SCAR=24.8
70 0 my ($self, $level, $thing) = @_;
71  
72 0 my $h = $self->{private_DBIx_Log4perl};
73  
74 0 ▶ return unless $h->{logger}->is_info();
Branch: 1 branch
BranchTrueFalseTotal
unless $h->{"logger"}->is_info 0 0 0
75  
76 0 ▶ local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + $level
Branch: 1 branch
BranchTrueFalseTotal
if $level 0 0 0
77 if $level;
78  
79 0 $h->{logger}->info($thing);
80  
81 0 return;
82 }
83 0 ▶sub _dbix_l4p_warning {
Subroutine _dbix_l4p_warning: not called CC=5 SCAR=34.0
84 0 my ($self, $level, $thing, @args) = @_;
85  
86 0 my $h = $self->{private_DBIx_Log4perl};
87  
88 0 ▶ return unless $h->{logger}->is_warn();
Branch: 1 branch
BranchTrueFalseTotal
unless $h->{"logger"}->is_warn 0 0 0
89  
90 0 local $Data::Dumper::Indent = 0;
91 0 local $Data::Dumper::Quotekeys = 0;
92  
93 0 ▶ local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + $level
Branch: 1 branch
BranchTrueFalseTotal
if $level 0 0 0
94 if $level;
95  
96 0 ▶ if (scalar(@args) > 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @args > 1) { } 0 0 0
elsif (ref $args[0]) { } 0 0 0
97 $h->{logger}->warn(
98 0 ▶ sub {Data::Dumper->Dump([\@args], [$thing])})
Subroutine __ANON__: not called CC=1 SCAR=6.9
99 0 } elsif (ref($args[0])) {
100 $h->{logger}->warn(
101 0 ▶ sub {Data::Dumper->Dump([$args[0]], [$thing])})
Subroutine __ANON__: not called CC=1 SCAR=6.9
102 0 } else {
103 0 $h->{logger}->warn("$thing: " . DBI::neat($args[0]));
104 }
105 0 return;
106 }
107  
108 0 ▶sub _dbix_l4p_error {
Subroutine _dbix_l4p_error: not called CC=6 SCAR=37.4
109 0 my ($self, $level, $thing, @args) = @_;
110  
111 0 my $h = $self->{private_DBIx_Log4perl};
112  
113 0 ▶ return unless $h->{logger}->is_error();
Branch: 1 branch
BranchTrueFalseTotal
unless $h->{"logger"}->is_error 0 0 0
114  
115 0 local $Data::Dumper::Indent = 0;
116 0 local $Data::Dumper::Quotekeys = 0;
117  
118 0 ▶ local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + $level
Branch: 1 branch
BranchTrueFalseTotal
if $level 0 0 0
119 if $level;
120  
121 0 ▶ if (scalar(@args) > 1) {
Branch: 3 branches
BranchTrueFalseTotal
if (scalar @args > 1) { } 0 0 0
elsif (ref $thing eq 'CODE') { } 0 0 0
elsif (ref $args[0]) { } 0 0 0
122 $h->{logger}->error(
123 0 ▶ sub {Data::Dumper->Dump([\@args], [$thing])})
Subroutine __ANON__: not called CC=1 SCAR=6.9
124 0 } elsif (ref($thing) eq 'CODE') {
125 0 $h->{logger}->error($thing);
126 } elsif (ref($args[0])) {
127 $h->{logger}->error(
128 0 ▶ sub {Data::Dumper->Dump([$args[0]], [$thing])})
Subroutine __ANON__: not called CC=1 SCAR=6.9
129 0 } else {
130 0 $h->{logger}->error("$thing: " . DBI::neat($args[0]));
131 }
132 0 return;
133 }
134  
135 0 ▶sub _dbix_l4p_attr_map {
Subroutine _dbix_l4p_attr_map: not called CC=1 SCAR=6.9
136 0 return {dbix_l4p_logger => 'logger',
137 dbix_l4p_init => 'init',
138 dbix_l4p_class => 'class',
139 dbix_l4p_logmask => 'logmask',
140 dbix_l4p_ignore_err_regexp => 'err_regexp'
141 };
142 }
143  
144 0 ▶sub dbix_l4p_getattr {
Subroutine dbix_l4p_getattr: not called CC=4 SCAR=30.0
Pod documented
145 0 my ($self, $item) = @_;
146  
147 0 ▶ croak ('wrong arguments - dbix_l4p_getattr(attribute_name)')
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ != 2 or not defined $_[1] 0 0 0
Condition0%0/3
scalar @_ != 2 or not defined $_[1]
l!l&&r!l&&!r
000
MC/DC0%0/2
scalar @_ != 2 or not defined $_[1]
scalar @_ != 2 not defined $_[1]
Truth table0%0/3
A or not(B)
A= scalar @_ != 2B= not defined $_[1]
ABresult
1X1
011
000
148 if (scalar(@_) != 2 || !defined($_[1]));
149  
150 0 my $m = _dbix_l4p_attr_map();
151  
152 0 my $h = $self->{private_DBIx_Log4perl};
153  
154 0 ▶ if (!exists($m->{$item})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $m->{$item}) 0 0 0
155 0 warn "$item does not exist";
156 0 return undef;
157 }
158 0 return $h->{$m->{$item}};
159 }
160  
161 0 ▶sub dbix_l4p_setattr {
Subroutine dbix_l4p_setattr: not called CC=4 SCAR=30.0
Pod documented
162 0 my ($self, $item, $value) = @_;
163  
164 0 ▶ croak ('wrong arguments - dbix_l4p_setattr(attribute_name, value)')
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ != 3 or not defined $_[1] 0 0 0
Condition0%0/3
scalar @_ != 3 or not defined $_[1]
l!l&&r!l&&!r
000
MC/DC0%0/2
scalar @_ != 3 or not defined $_[1]
scalar @_ != 3 not defined $_[1]
Truth table0%0/3
A or not(B)
A= scalar @_ != 3B= not defined $_[1]
ABresult
1X1
011
000
165 if (scalar(@_) != 3 || !defined($_[1]));
166  
167 0 my $m = _dbix_l4p_attr_map();
168  
169 0 my $h = $self->{private_DBIx_Log4perl};
170  
171 0 ▶ if (!exists($m->{$item})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $m->{$item}) 0 0 0
172 0 warn "$item does not exist";
173 0 return undef;
174 }
175 0 $h->{$m->{$item}} = $value;
176 0 1;
177 }
178  
179 0 ▶sub connect {
Subroutine connect: not called CC=5 SCAR=34.0
Pod documented
180  
181 0 my ($drh, $dsn, $user, $pass, $attr) = @_;
182  
183 0 my $dbh = $drh->SUPER::connect($dsn, $user, $pass, $attr);
184 0 ▶ return $dbh if (!$dbh);
Branch: 1 branch
BranchTrueFalseTotal
unless $dbh 0 0 0
185  
186 #
187 # Enable dbms_output for DBD::Oracle else turn off DBDSPECIFIC as we have
188 # no support for DBDSPECIFIC in any other drivers.
189 # BUT only enable it if the log handle is doing debug as we only call
190 # dbms_output_get in that case.
191 #
192 0 my $h = $dbh->{private_DBIx_Log4perl};
193 0 $h->{dbd_specific} = 1;
194 0 ▶ if (($h->{logger}->is_debug()) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($h->{'logger'}->is_debug and $h->{'logmask'} & 128 and $h->{'driver'} eq 'Oracle') { } 0 0 0
Condition0%0/6
$h->{"logger"}->is_debug and $h->{"logmask"} & 128 and $h->{"driver"} eq "Oracle"
!ll&&!rl&&r
000
$h->{"logger"}->is_debug and $h->{"logmask"} & 128
!ll&&!rl&&r
000
MC/DC0%0/3
$h->{"logger"}->is_debug and $h->{"logmask"} & 128 and $h->{"driver"} eq "Oracle"
$h->{"logger"}->is_debug $h->{"logmask"} & 128 $h->{"driver"} eq "Oracle"
Truth table0%0/4
A and B and C
A= $h->{"logger"}->is_debugB= $h->{"logmask"} & 128C= $h->{"driver"} eq "Oracle"
ABCresult
0XX0
10X0
1100
1111
195 ($h->{logmask} & DBIX_L4P_LOG_DBDSPECIFIC) &&
196 ($h->{driver} eq 'Oracle')) {
197 0 $dbh->func('dbms_output_enable');
198 } else {
199 0 $h->{logmask} &= ~DBIX_L4P_LOG_DBDSPECIFIC;
200 }
201 0 $h->{dbd_specific} = 0;
202 0 return $dbh;
203 }
204  
205 sub dbix_l4p_logdie
206 0 ▶{
Subroutine dbix_l4p_logdie: not called CC=1 SCAR=6.9
Pod documented
207 0 my ($drh, $msg) = @_;
208 0 _error_handler($msg, $drh);
209 0 die "$msg";
210 }
211  
212 2 1;
213  
214 __END__
« Log4perl/st.pm ↑ Summary Log4perl/Constants.pm »